How to remove service from systemd?

Systemd is a widely used service manager in modern Linux. It simplifies starting, stopping, enabling, and disabling services. However, you may need to remove service from systemd at some point. This guide will walk you through the steps.

Systemctl Stop 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.

Systemctl Disable 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.

Systemctl 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 /etc/systemd/system/ directory. Hence, use the 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.

Sharing Is Caring:
Subscribe
Notify of
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments