How to Start, Stop and Restart Services in Ubuntu


Services are programs that execute in the background and perform several tasks such as managing network connections, printing, logging, etc. In Ubuntu 22.04, services are managed by a system called systemd, which provides a consistent and powerful way to control them. Services can be controlled by using commands or graphical tools.

This post will explain the following methods in detail to start, stop, as well as restart services on Ubuntu-based operating system:

  • Using systemctl Command
  • Using service Command
  • Using System Monitor (GUI)

Method 1: Using “systemctl” Command to Start, Stop and Restart a Service

The systemd commands are utilized to start, stop, as well as restart services in Ubuntu-based Linux systems. Now, we will also show how to check the status and list the available services on the system.

Start a Service

For starting a service, users require to utilize the below syntax:

sudo systemctl start service_name

In the above syntax, the “service_name” represents the name of the service users need to start.
So, to start the SSH service, you would type:

sudo systemctl start ssh

Stop a Service

To stop a service, users need to utilize the command syntax:

sudo systemctl stop service_name

In this syntax, the “service_name” identifies the name of the service users need to stop.
Likewise, to stop the SSH services, users would type:

sudo systemctl stop ssh

Restart a Service

For restarting the particular service, users need to use the command:

sudo systemctl restart service_name

In this syntax, the “service_name” identifies the name of the service you need to restart. This command first stops and after that initializes the service again.
Accordingly, to restart the SSH services, you would type:

sudo systemctl restart ssh

Check the Status of a Particular Service

To visualize the service status, users need to utilize the command:

sudo systemctl status service_name

Here, “service_name” is the name of the service users want to check. This command will show information such as whether the service is running or not, how long it has been running, and any error messages or logs.
Therefore, to check the status of the SSH, we would type:

sudo systemctl status ssh

A picture containing text, screenshot, font Description automatically generated

Enlist All the Available Services

To enlist all the services on the system, users need to utilize the script:

sudo systemctl list-unit-files --type=service

A screenshot of a computer program Description automatically generated with medium confidence
It shows a table with the names and statuses of services on the system.

Method 2: Using “service” Command to Start, Stop and Restart a Service

Another command that can be utilized to manage services is service. This command is similar to systemctl but has a different syntax.

Start the Service

For example, to initialize the ssh service, users can utilize the below script:

sudo service ssh start

Stop the Service

To stop the ssh service, users can execute the following script:

sudo service ssh stop

Restart the Service

To restart the ssh service, users can execute:

sudo service ssh restart

Check the Status of the Particular Service

To check the status of the ssh service, you can use:

sudo service ssh status

A picture containing text, screenshot, font Description automatically generated

List All the Services

To list all the services on the system, use the below script:

sudo service --status-all

A screenshot of a computer Description automatically generated

Method 3: Using System Monitor to Start, Stop and Restart Services (GUI)

A GUI tool that can be utilized to manage services is GNOME System Monitor. This tool can be accessed by searching for “System Monitor” in the Activities overview or by typing gnome-system-monitor in a terminal. Let’s search the application name in Activities and open it:

This tool shows information about processes, resources, and file systems on the system.

Start, Stop, and Restart Services

Users can also use it to start, stop and restart services by selecting a service from the “Processes” tab and clicking on the “End Process” or “Kill Process” buttons:

In this way, you can start, stop as well as restart the services with graphical representation.

Conclusion

To start, stop and restart a service on Linux, users can utilize the “systemctl” command and the “service” command. The systemctl is the preferred way for managing services on operating systems. The service command is a wrapper for systemctl that assists in compatibility with older operating systems. Users can also utilize the “System Monitor” GUI application to modify services.

Print Friendly, PDF & Email
Categories