Restarting a service is one of the administrative tasks that you will have to perform one time or the other while configuring software on your Ubuntu. In this article, we will explain how to restart a running service on your Ubuntu through the systemctl command. We will also explain some more service management systemctl commands that will help you further while working with services.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.

Restarting a Service with Systemctl

In this article, we will be using the Ubuntu command line, the Terminal, in order to explain how to restart a running service.

You can open the Terminal application on your Ubuntu either through the application launcher search bar or simply through the Ctrl+Alt+T shortcut.

The latest versions of Ubuntu use systemd to control and start services. To get a list of all enabled systemd units, run this command:

systemctl list-unit-files | grep enabled
Systemd Unit list

The list will help you in fetching the exact service name that you can later use to restart the service.

You can use the systemctl command in order to restart a service. This command is a relatively new tool that you can use to control systemd (init system) and services. This tool is the replacement of the sysV init manager. These days, most modern Linux distros have switched to systemd and thus systemctl.

Here is how you can use the systemctl command in order to restart a running service:

$ sudo systemctl restart [servicename]

For example, the following command can be used to restart the UFW( Uncomplicated Firewall) service on Ubuntu:

$ sudo systemctl restart ufw

Please note that you need to be an authorized user in order to manage system services.

Manage Services with Systemd

Not only you can restart services with systemctl, but you can also:

  • Check the status of a service

$ systemctl status [servicename]

$ systemctl start [servicename]

$ systemctl stop [servicename]

  • Reload a service (reload service configuration)

$ systemctl reload [servicename]

  • Reload-or-restart a service (reloads a service/restarts if reload is not available)

$ sudo systemctl reload-or-restart [servicename]

$ systemctl enable [servicename]

$ systemctl disable [servicename]

  • Check if service is enabled/active

$ sudo systemctl is-active [servicename]

$ sudo systemctl is-enabled [servicename]

Through this simple, yet useful tool you can restart a service without having to restart your entire system. Not only that, you can perform more service management with the help of the command usage described in this article.

How to Restart Services on Ubuntu Command Line