Systemd is a popular system and service manager used in many modern Linux distributions. It provides a centralized way of managing services on our system, making it easier to start, stop, enable, and disable them. However, there may come a time when we need to remove a service from systemd. In this blog post, I will walk you through the steps on how to remove a service from systemd.
Stop the service
The first step to remove service from systemd is to stop the service. We can do this by using the systemctl stop
command followed by the name of the service to stop it.
Example:
sudo systemctl stop <service-name>
This will stop the service from running on our system.
Disable the service
The next step is to disable the service. This will prevent it from starting up automatically when our system boots up. To do this, use the systemctl disable
command followed by the name of the service to disable it.
Example:
sudo systemctl disable <service-name>
This will disable the service from starting up automatically.
Remove service file
After disabling the service, the next step is to remove the service file from the /etc/systemd/system
directory. Because in most of the cases our service file will be inside
directory. Hence, use the /etc/systemd/system/
rm
command to remove the service file from the /etc/systemd/system
directory.
Example:
sudo rm /etc/systemd/system/<service-name>
This should remove the service file from our system.
Reload the daemon
Use the systemctl daemon-reload
command to reload the systemd
daemon and remove the service compeletely.
Example:
sudo systemctl daemon-reload
Clean up
Finally, use the systemctl reset-failed
command to remove any failed state entries for the service.
Example:
sudo systemctl reset-failed
After following the steps mentioned above it should remove the service from systemd
.