10

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.

4 Answers 4

12

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. :-)

1
  • for example: sudo update-rc.d postgresql disable
    – Lluís
    Nov 21, 2012 at 22:48
5

You can try "sysv-rc-conf" utility to make your life little easier. It is more of chkconfig tool of other system.

Just type at the promp:

sudo apt-get install sysv-rc-conf

Cheers!

1
  • Nice tool, thanks. I see that it also correctly disables services (i.e. by renaming the symlink to K...).
    – Heinzi
    Jan 18, 2010 at 12:06
2

Actually, sysv-rc-conf is the approach recommended even by update-rc.d man page:

Please note that this program was designed for use in package maintainer scripts and, accordingly, has only the very limited functionality required by such scripts. System administrators are not encouraged to use update-rc.d to manage runlevels. They should edit the links directly or use runlevel editors such as sysv-rc-conf and bum instead.

0

As I understood it, the "Debian best practice" is to uninstall the package. You shouldn't have packages installed if you're not using them. This is why Debian packages are all configured to start on installation.

(Those few packages that could be useful to have installed without running usually have a setting in their /etc/default/<packagename> configuration files to disable starting.)

1
  • 2
    you misunderstand. "not start automatically at boot" doesn't imply "not using the package at all". as one simplistic example, i might want my SSH server started by xinetd as needed, instead of starting up as a daemon at boot. Feb 10, 2010 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .