Categories: DebianLinuxShell

How to restart a service via systemctl under Linux

A service is a background process that automatically runs when you boot up your system. For regular users and especially system administrators, restarting a service is a common system administration task that you often have to perform while configuring system settings or installing a new application.

In this article, we will learn about how to restart a service through systemctl on Linux. Systemctl is basically a command-line system application that is used to manage the system services and allows to start, stop, restart, enable, disable, and view the status of the services.

We have used Debian 10 for running the commands and procedures mentioned in this article, but the same commands will work on other Distributions like Ubuntu, CentOS or Fedora too.

Restarting a Service with Systemctl

To restart a service, command-line Terminal is used. In order to open the Terminal, go to the Activities tab in the top left corner of your desktop. Then from the search menu that appears, search for the Terminal application and launch it.

To list all enable services on your system, run the following command in Terminal:

$ systemctl list-unit-files | grep enabled

From the above list, you can find out the exact name of the service you want to restart using the systemctl command.

In order to restart a running service(Stop and then start), use the following command syntax in Terminal:

$ sudo systemctl restart [service-name]

For instance, to restart the xrdp service, replace the "service-name" parameter with the exact name of the service.

Manage Services with Systemd

Along with service restart, you can also manage service using systemctl command such as start, stop, enable, disable, and viewing the status of service.

In order to view the current status of the service whether it is running or not, use the following command syntax in Terminal:

$ systemctl status [service-name]

In order to start a service, use the following syntax:

$ systemctl start [service-name]

In order to stop a running service, use the following syntax:

$ systemctl stop [service-name]

In order to enable a service to automatically start on boot, use the following syntax:

$ systemctl enable [service-name]

In order to disable service to not automatically start on boot, use the following syntax:

$ systemctl disable [service-name]

In order to reload a service, use the following syntax:

$ systemctl reload [service-name]

In order to reload-or-restart a service (It reloads a service and in case, if reload is not available then it restarts the service.)

$ sudo systemctl reload-or-restart [service-name]

In order to check if service is active:

$ sudo systemctl is-active [service-name]

In order to check if service is enabled to automatically start on a system boot:

$ sudo systemctl is-enabled [service-name]

In this article, we have learned how to restart a service through the systemctl command. We also learned other common use of systemctl command for managing the services.

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