Setting up a daemon to run automatically at startup

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

If I sudo to root and run:

ls -alh /etc/rc2.d/

I see something like this:

Apparently, on Ubuntu, the creation of these links is managed by update-rc.d

DESCRIPTION
update-rc.d updates the System V style init script links
/etc/rcrunlevel.d/NNname whose target is the script /etc/init.d/name.
These links are run by init when it changes runlevels; they are
generally used to start and stop system services such as daemons.
runlevel is one of the runlevels supported by init, namely,
0123456789S, and NN is the two-digit sequence number that determines where in the sequence init will run the scripts.

This manpage documents only the usage and behaviour of update-rc.d. For a discussion of the System V style init script arrangements please see init(8) and the Debian Policy Manual.

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.

When run with either the defaults, multiuser, start, or stop options,
update-rc.d makes links /etc/rcrunlevel.d/[SK]NNname that point to the
script /etc/init.d/name.

If any files /etc/rcrunlevel.d/[SK]??name already exist then update-
rc.d does nothing. The program was written this way so that it will
never change an existing configuration, which may have been customized
by the system administrator. The program will only install links if
none are present, i.e., if it appears that the service has never been
installed before.

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.

Post external references

  1. 1
    http://manpages.ubuntu.com/manpages/hardy/man8/update-rc.d.8.html
Source