This tutorial explains how to start, stop and restart services in Debian 11 Bullseye using both systemctl and service commands.

Services on Linux Debian 11

A service is a program running in the background to be used when needed. Apache, ssh, Nginx or Mysql are some of the most known services. On Debian, including Debian 11 Bullseye, services are managed with Systemd, the replacement of System V to initialize the system and its components, including services.

Start, Stop and Restart Services on Debian 11 Using Systemd

The Systemd is a suite to manage Linux services and daemons (the last “d” is because of Unix daemons). The systemctl command allows to start, stop, restart and check services status. Its aim is to unify the configuration and behaviour for all Linux distributions replacing the old Unix SystemV and BSD init systems.

This tutorial section shows execution examples of the actions described in the following table.

ACTION COMMAND
Check service status sudo systemctl status
Stop a service sudo systemctl stop
Start a service sudo systemctl start
Restart a service sudo systemctl restart

As shown in the previous table, the syntax to check the status of a service using Systemd is the following:

systemctl status <Service-Name>

Therefore, to check the status of the ssh service you can run the following command.

sudo systemctl status ssh

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-1.png" data-lazy- height="611" src="data:image/svg xml,” width=”1326″>

As you can see in the screenshot above, the ssh service is active and properly running.

To stop a service, the syntax is similar, just replace the status option with the action you want to execute, in this case the action is to stop.

For example, to stop the ssh service run the command below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-2.png" data-lazy- height="643" src="data:image/svg xml,” width=”1290″>

As you can see, after stopping the service and checking the status, the ssh service now appears as inactive (dead).

To start a service, just replace stop with start, as shown in the screenshot below. To start the ssh service, run:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-3.png" data-lazy- height="626" src="data:image/svg xml,” width=”1293″>

As you can see, the service is running again.

To restart a service, the option you need to type is restart. The following command is used to restart the ssh service.

sudo systemctl restart ssh

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-4.png" data-lazy- height="112" src="data:image/svg xml,” width=”841″>

That’s how services are restarted using Systemd.

You can get additional information on Systemd at https://systemd.io/.

Stop, Start and Restart Services on Debian 11 Using the Service Command

The service command is used to manage services under the /etc/init.d directory despite some distributions redirecting the command to the previously explained systemctl command.

This command can also be used to stop, start and restart services following the syntax described in the table below.

ACTION COMMAND
Check service status sudo service status
Stop a service sudo service stop
Start a service sudo service start
Restart a service sudo service restart

This section shows examples of application of the commands described in the above table.

To check the status of a service (ssh in this case) using the service command, use the syntax shown below. Replace “ssh” with the service you want to check.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-5.png" data-lazy- height="431" src="data:image/svg xml,” width=”1312″>

As you can see, the ssh service is active and running properly.

The command shown in the screenshot below is used to stop services. Run it to stop the ssh service, or replace “ssh” with the service you want to stop.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-6.png" data-lazy- height="396" src="data:image/svg xml,” width=”1293″>

As you can see, after running service ssh stop, ssh is now inactive.

To start the ssh service back, use the following syntax. Remember to replace “ssh” with the service you want to load.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-7.png" data-lazy- height="462" src="data:image/svg xml,” width=”1299″>

Finally, to restart services using the service command, use the syntax below.

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/10/echo/Stop-Start-and-Restart-Services-on-Debian-8.png" data-lazy- height="425" src="data:image/svg xml,” width=”1308″>

As you can see, the service runs properly.

The following command can be used to reload a service configuration without interrupting the service itself.

You can get more information on the service command at https://linux.die.net/man/8/service.

Conclusion

Services are an essential component of any device. Managing services properly is a must for any Linux level user. As you could see with this tutorial, managing services is pretty simple and can be done through different methods. Always keep in mind the recommended method to deal with services in Linux is the systemctl command explained in the first section of this article. Other methods (like dealing directly with the /etc/init.d directory) are considered obsolete, and were removed from the first version of this tutorial. All commands explained in this tutorial are useful to stop,start, restart and check service status, but there are additional functions you can learn on their respective man pages.

Thank you for reading this tutorial explaining how to stop, start and restart services on Debian 11. Keep following us for additional Linux tips and tutorials.