This article explains how to start, stop and restart services in Debian 11 Bullseye using both systemctl and utility commands.
Services in Linux Debian 11
A service is a program that runs in the background and is used when needed. Apache, ssh, Nginx or Mysql are some of the best known services. In Debian, including Debian 11 Bullseye, services are managed using Systemd, replacing System V to initialize the system and its components, including services.
Starting, stopping and restarting services in Debian 11 using Systemd
Systemd is a package for managing Linux services and daemons (the last d is for Unix daemons). The systemctl command allows you to start, stop, restart, and check the status of services. Its goal is to unify configuration and behavior across all Linux distributions, replacing the old Unix init systems SystemV and BSD.
This section of the guide shows examples of how to perform the steps in the following table.
|Check service status||sudo systemctl status |
|Stop service||sudo systemctl stop |
|Start the service||sudo systemctl start |
|Restart service||sudo systemctl restart |
As shown in the previous table, the syntax for checking the status of a service using Systemd is as follows:
systemctl status <Имя службы>
Hence, to check the status of the ssh service, you can run the following command.
sudo systemctl status ssh
To stop the service, the syntax is the same, just replace the status parameter with the action you want to perform, in which case the action should be stop.
For example, to stop the ssh service, run the command below.
sudo systemctl stop ssh
To start the service, simply replace stop with start. To start the ssh service, run:
sudo systemctl start ssh
To restart the service, you need to enter the restart parameter. The following command is used to restart the ssh service.
sudo systemctl restart ssh
This is how services are restarted using Systemd.
You can get more information about Systemd at https://systemd.io/.
Stopping, starting and restarting services in Debian 11 using a service command
The service command is used to manage services in the /etc/init.d directory, although some distributions redirect the command to the previously described systemctl command.
This command can also be used to stop, start, and restart services by following the syntax described in the table below.
|Check service status||sudo service |
|Stop service||sudo service |
|Start the service||sudo service |
|Restart service||sudo service |
This section shows examples of how to use the commands described in the table above.
To check the status of a service (in this case ssh) using the service command, use the syntax shown below. Replace “ssh” with the service you want to test.
sudo service ssh status
The command shown in the screenshot below is used to stop services. Start it to stop the ssh service, or replace “ssh” with the service you want to stop.
sudo service ssh stop
To start the ssh service again, use the following syntax. Remember to replace “ssh” with the service you want to load.
sudo service ssh start
Finally, to restart services using the service command, use the syntax below.
sudo service ssh restart
The following command can be used to reload the configuration of a service without interrupting the service itself.
sudo service ssh reload
You can get more information about the service command at https://linux.die.net/man/8/service.
Services are an integral part of any device. Proper service management is a must for any Linux user. As you can see from this tutorial, service management is pretty simple and can be done in many different ways. Always remember that the recommended method for working with services on Linux is the systemctl command, described in the first section of this article. Other methods (for example, working directly with the /etc/init.d directory) are deprecated and have been removed from the first version of this guide. All of the commands in this guide are useful for stopping, starting, restarting, and checking the status of a service, but there are additional features that you can learn from their respective manual pages.
Thank you for reading this article, which explains how to stop, start and restart services in Debian 11. Follow us for more Linux tips and guides.