Previous Section  < Day Day Up >  Next Section

Recipe 7.5. Managing Debian's Runlevels

7.5.1 Problem

You need to manage what services start up at boot on a Debian system, on each runlevel, because when you install new services, such as Apache, Exim, or OpenSSH, Debian configures them to start at boot. You're still testing things, so you want to start/stop them manually. Or you want different services to start on different runlevels during testing.

7.5.2 Solution

Use the update-rc.d command. This example adds a new service, the KDE Display Manager, to runlevel 5. kdm is the name of a startup file in /etc/init.d. There must be a trailing dot ending the runlevels list:

# update-rc.d kdm  start 99 5 . stop 01 0 1 2 3 4 6 .

This command removes a service from all runlevels. Removal is all or nothing; you cannot be selective:

# update-rc.d -f kdm remove

Changing the runlevels for an existing service is a two-step process: first remove it, then add it back to the levels in which you want it to run. Be sure to make an entry for every service on every runlevel, either stop or start.

7.5.3 Discussion

Remember, update-rc.d operates on the script names in /etc/init.d. You can test-drive the update-rc.d commands with the -n option, which means "not really":

# update-rc.d -f -n kdm remove

You can delete init.d scripts if you really really want to, with the remove option:

# update-rc.d —purge kdm remove

But it's usually better to leave them in place, because you may want them again.

7.5.4 See Also

  • update-rc.d(8)

    Previous Section  < Day Day Up >  Next Section