From LQWiki
Jump to: navigation, search

update-rc.d is the Debian utility to install and remove System-V style init script links. Other distributions (such as Red Hat) use chkconfig. With update-rc.d, you can schedule tasks to be started when you boot your computer, for example the ssh service.


Q. I deleted update-rc.d, how can I get it back again?

A. Go here http://www.debian.org/distrib/packages and then choose the textbox to search for files in packages... easy if you know :-) Usually this package is called something like sysv-rc. Now download this package. Then comes the tricky part because without update-rc.d installing a package is not trivial. A chicken and egg problem. Use the ar program to extract the contents of the package (ar xv sysv-rc), then extract the contents of the resulting files. Somewhere in this mess you will find update-rc.d, which you should copy to /usr/sbin/. Now the normal debian package managers will probably work again.

Q. How do I install a System-V style init script ?

A. As root (through su, sudo, etc.) run:

$ update-rc.d script_name defaults 

Q. How do I remove a System-V init script ?

A. First you most remove the original script in /etc/init.d. Then, to remove the links in /etc/rcrunlevel.d run (as root):

$ update-rc.d script_name remove

Q. How do I disable a System-V init script so it will remain disabled on upgrade ?

A. Run (as root):

$ update-rc.d script_name disable

Reference: [1] section "3.6.1 Disabling daemon services"

Q. What does the argument defaults do?

A. If defaults is used, update-rc.d will make links to start the service in runlevels 2345, and stop the service in runlevels 016.

Q. Are there any other arguments?

A. Yes, you can use the arguments start and stop, followed by NN (where NN are the desired runlevels) to specify which runlevels the script will start and stop in.

Q. Can you provide an example with the start and stop arguments?

A. To start the script folding in runlevels 0123 and stop in 456, run (as root):

$ update-rc.d folding start 0123 stop 456

See also