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.
1. Stop the service
The first step in removing a 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.
sudo systemctl stop <service-name>
This will stop the service from running on our system.
2. 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.
sudo systemctl disable <service-name>
This will disable the service from starting up automatically.
3. 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
rm command to remove the service file from the
sudo rm /etc/systemd/system/<service-name>
This should remove the service file from our system.
4. Reload the daemon
systemctl daemon-reload command to reload the
systemd daemon and remove the service compeletely.
sudo systemctl daemon-reload
5. Clean up
Finally, use the
systemctl reset-failed command to remove any failed state entries for the service.
sudo systemctl reset-failed
After following the steps mentioned above it should remove the service from