How to Start, Stop or Restart Services in Ubuntu

As with all other operating systems, Linux has services and other processes that run in the background to perform certain important functions while the system is running. When the system is booted, the services start automatically and continue to run in the background until the system is shut down. However, you can also start, stop and restart the services manually.

In this article, I'll show you different methods for starting, stopping, and restarting services in Ubuntu. The article covers systemd, the service command, and init scripts. These commands work on all current versions of Ubuntu, including the new Ubuntu 22.04.

List all services in Ubuntu

Before we start, I will show you how to get a list of all the services on your computer as we need to know the service name to manage the service.

service --status-all

It will show a complete list of services on Ubuntu.

List services in Ubuntu

Use Systemd to Start/Stop/Restart Services in Ubuntu

You can start, stop or restart services using Systemd systemctl utility. This is the preferred way on current Ubuntu versions like Ubuntu 18.04, Ubuntu 20.04, and Ubuntu 22.04.

Open up a terminal window, and enter the following commands. For instance, in this case, I want to start, stop or restart the UFW Firewall service in Ubuntu.

The Syntax is:

sudo systemctl [action] [service name]

To start a service:

sudo systemctl stop ufw

To stop a service:

sudo systemctl start ufw

To restart a service:

sudo systemctl restart ufw

To check the status of service:

sudo systemctl status ufw

Manage services with systemd

Start/Stop/Restart Services with service command on Ubuntu

You can start, stop, or restart services using the service command too. Open up a terminal window, and enter the following commands.

To start a service:

sudo service ufw stop

To stop a service:

sudo service ufw start

To stop a service:

sudo service ufw restart

To check the status of a service:

sudo service ufw status

Manage services with the service command on Ubuntu

Using Init scripts to manage services on Ubuntu

You can start, stop or restart services using init scripts in the /etc/init.d directory. This directory actually consists of various scripts for different services. Init scripts are deprecated since Ubuntu switched to Systemd, so this method will be used only if you have to deal with an old Ubuntu version. Open up a terminal window, and enter the following commands.

To start a service:

/etc/init.d/ufw start

To stop a service:

/etc/init.d/ufw stop

To stop a service:

/etc/init.d/ufw restart

To check the status of service:

/etc/init.d/ufw status

Manage services by using init scripts

That is how you can start, stop, and restart services using different ways without restarting the whole operating system. You can also use these commands in other Linux distributions.