Debian – Recommended Way to Disable a Service in Debian

bootdebianlinuxservice

Is there a "recommended way" to disable a service in Debian? (Disable = The service is installed but won't start automatically when the machine boots.)

I know that you can update-rc.d -f service remove (which basically removes the links in rcX.d), but doing this you lose the sequence number of the service (SXXservice, with XX being the sequence number), making life harder when you want to re-enable the service. I also know that I can just rename the links in rcX.d so that they don't start with S (or move them somewhere else), but I wondered if there is some "Debian-approved best-practice" way to do this.

Best Answer

Have a look at the update-rc.d man page. The third paragraph of the section named Installing Init Script Links reads …

A common system administration error is to delete the links with the thought that this will "disable" the service, i.e., that this will prevent the service from being started. However, if all links have been deleted then the next time the package is upgraded, the package's postinst script will run update-rc.d again and this will reinstall links at their factory default locations. The correct way to disable services is to configure the service as stopped in all runlevels in which it is started by default. In the System V init system this means renaming the service's symbolic links from S to K.

The last two sentences should answer your question. :-)

Related Topic