Categories: LinuxShellUbuntu

How to Restart Services on Ubuntu Command Line

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

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]

  • Start a service

$ systemctl start [servicename]

  • Stop a service

$ 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]

  • Enable a service

$ systemctl enable [servicename]

  • Disable a service

$ 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.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago