How to Disable Autostart for a Service on VPS?
Often, VPS server owners face the need to disable the autostart of a specific service. This can be due to various reasons, such as not wanting to waste server resources on running an unnecessary service or wanting to resolve a problem with program conflicts.
There are several ways to disable autostart for a service on VPS. Let’s examine them in detail.
1. Using the Command Line
The easiest way to disable autostart for a service is to use the command line. To do this, you need to perform the following steps:
systemctl stop servicename— stop the service;systemctl disable servicename— disable the autostart of the service;systemctl status servicename— check the service status.
After executing these commands, the service will be stopped and will no longer start automatically when the server reboots.
2. Editing the Configuration File
Another way to disable autostart for a service is to edit the configuration file. To do this, you need to find the file responsible for autostarting the desired service, usually these are files in the /etc/systemd/system/ directory.
Open the file in a text editor and find the line containing the parameter WantedBy=default.target. Replace it with WantedBy=multi-user.target, this will disable the autostart of this service.
After making changes to the configuration file, you need to execute the command systemctl daemon-reload to apply the changes.
Conclusion
Disabling autostart for a service on VPS is an important task that will help optimize server performance and eliminate potential problems. Use the suggested methods to manage service startup and make your VPS more efficient.