Previous Section  < Day Day Up >  Next Section

Recipe 7.7. Managing Red Hat's Runlevels

7.7.1 Problem

Unless you took the time to do a custom installation, Red Hat/Fedora typically starts all kinds of services when it boots. If you took the fast way, you probably have all sorts of services running that you'd like to shut off. Or you'd like to start different services on different runlevels, for testing and tinkering.

7.7.2 Solution

Use chkconfig. For example, configuring ssh:

# chkconfig —level 2345 ssh on

# chkconfig —level 016 ssh off

You need both steps—define which runlevels the service will run on, and define which runlevels it will not run on. "Off" means kill, and "on" means start.

To add a new service to all levels, use:

# chkconfig —add ssh

To delete a service from all runlevels, use:

# chkconfig —del ssh

xinetd services are slightly different, and are also managed with chkconfig:

# chkconfig ktalk on

# chkconfig rsync off

xinetd services are either on or off; you don't have to worry about different runlevels.

To display the status of all services, on all runlevels, and xinetd services, use:

# chkconfig —list

anacron  0:off  1:off  2:on   3:on   4:on   5:on   6:off

syslog   0:off  1:off  2:on   3:on   4:on   5:on   6:off

cups     0:off  1:off  2:on   3:on   4:on   5:on   6:off

apmd     0:off  1:off  2:on   3:on   4:on   5:on   6:off

xinetd based services:

      chargen-udp    off

      rsync:         off

      sgi-fam:       on

To query a single service, use:

# chkconfig —list syslog

syslog   0:off  1:off  2:on   3:on   4:on   5:on   6:off

7.7.3 Discussion

chkconfig gets its default priority and runlevel values from the program's startup script. For example, in /etc/rc.d/init.d/cups:

#  Linux chkconfig stuff

#  chkconfig 2345 90 10

This tells chkconfig to start in runlevels 2, 3, 4, and 5, with a priority of 90 for starting and 10 for stopping. Of course, you can easily change these to suit yourself, by either editing the original init.d script or simply renaming the links:

# mv /etc/rc.d/rc3.d/S90cups /etc/rc.d/rc3.d/S45cups

7.7.4 See Also

    Previous Section  < Day Day Up >  Next Section