Raspberry Pi

How to stop services on the Raspberry Pi operating system

The Raspberry Pi OS is a Debian-based Linux operating system that is recommended to use on Raspberry Pi devices. In the Raspberry Pi, we can install different packages like SSH and Apache which are known as the services, and some ports are assigned to them for their processing. These services can be stopped, started, and managed in the Raspberry Pi by using different commands in the terminal.

In this write-up, we will explore the methods to stop and manage the services on the Raspberry Pi operating system.

How to stop the services on the Raspberry Pi using the systemctl command

We have a system known as the systemd which manages all the services running on the Raspberry Pi and to manage the systemd, we use the systemctl command in the terminal. Let’s say we want to find out the status of the services running in the Raspberry Pi, we simply run the command:

$ systemctl

These are the services running on the Raspberry Pi, now if we want to find out the status of any specific services, for understanding we will find the status of apache2 service using the systemctl command:

$ systemctl status apache2

The service of Apache2 is in running status, now if we want to stop the service of Apache2, we will use the systemctl command:

$ systemctl stop apache2

It will ask the authentication permission, so provide the password of the sudo user and press on the “OK” button. We can skip this step if we used the keyword of “sudo” at the start of the above-mentioned command, after providing the password, it will stop the process:

To confirm the status of Apache2, we will again check the status by using the systemctl command:

$ systemctl status apache2

The service of the Apache2 has been stopped, in a similar way we can manage any service running on the Raspberry Pi operating system by using the systemctl command.

How to stop the services on the Raspberry Pi using the service command

Another way to manage the services on the Raspberry Pi is by using the service command, to understand we will check the status of the ssh service by using the command:

$ sudo service ssh status

The ssh service is in the running status, now if we want to stop the ssh service using the service command:

$ sudo service ssh stop

To confirm the status of the ssh service, run the command:

$ sudo service ssh status

The SSH service has been successfully stopped.

Conclusion

Sometimes we want to stop the services because we are making the backup of the data or we want to reduce the load on the processor to improve the efficiency of the CPU of the Raspberry Pi. In this write-up, we have discussed the two different commands by which not only can stop any running service on the Raspberry Pi but also can check status, restart, and start the services.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.