sections in this module City College of San Francisco - CS260A
Unix/Linux System Administration

Module: StartupShutdown I
module list

Controlling Subsystems

As discussed in the previous section, the status and execution order of each subsystem at each runlevel is determined by the name and directory in which each symbolic link to the subsystem script exists. For example, the configuration for rsyslog can be seen by

$ cd /etc/rc.d
$ ls rc?.d/*rsyslog
rc0.d/K88rsyslog  rc2.d/S12rsyslog  rc4.d/S12rsyslog  rc6.d/K88rsyslog
rc1.d/K88rsyslog  rc3.d/S12rsyslog  rc5.d/S12rsyslog

$ ls rc2.d/S*{network,sshd}
rc2.d/S10network  rc2.d/S55sshd
$

Here, rsyslog is configured to be started at runlevels 2,3,4, and 5 and to be started after the network subsystem and before the sshd subsystem. This makes sense as rsyslog may do remote logging to another machine and it needs to log ssh connections. 

We can change the configuration of rsyslog by altering the configuration of symlinks in the rc?.d directories. For example, changing the name of rc2.d/S12rsyslog to rc2.d/K88rsyslog would change the runlevels that rsyslog is started at to runlevels 3,4 and 5.

This kind of reconfiguration is possible, but very messy and error-prone. Instead, one of two tools is used to reconfigure these symlinks for you:

The default state of a subsystem

As discussed previously, the author of a subsystem is best equipped to determine the default runlevels, and, more importantly, the order of starting and stopping. Thus, this information is embedded within the subsystem script itself in one of the now ubiquitous non-comment comments in the subsystem script itself:

$ grep chkconfig /etc/init.d/rsyslog
# chkconfig: 2345 12 88
$

When chkconfig is run and told to add the symlinks for rsyslog, it uses this comment to tell it the subsystem should be configured to be up at levels 2-5 and that the start order should be 12 and the kill order 88. If no such comment is found in the subsystem script, chkconfig will complain that the subsystem is not configured to be managed by chkconfig.

Using chkconfig

chkconfig --list [subsystem]   lists whether the indicated subsystem is configured to be started or stopped at each runlevel. If no subsystem name is given, all subsystems are listed. (chkconfig is in /sbin, which is not part of a normal user's PATH)

$ /sbin/chkconfig --list rsyslog
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off

chkconfig --del subsystem   deletes the configuration (symbolic links) for the subsystem

chkconfig --add subsystem   adds the configuration (creates the symbolic links) for the subsystem, using the configuration indicated in the special  #chkconfig comment.

chkconfig [ --level levels ] subsystem {on,off,reset}    changes the configuration of the indicated subsystem to on or off for the indicated levels. levels is a string of runlevels. If --level is missing, 2345 is used for the levels. reset resets the configuration for the levels to that indicated in the subsystem script.

ntsysv provides a simpler (or maybe just different) interface for configuring a subsystems runlevels, but it doesn't do anything that can't be done with chkconfig. See ntsysv(8)

Altering a subsystem's configuration

A subsystem can be added or removed from your system easily using chkconfig --add or chkconfig --del. This is important, as, when you install a system, the default configuration for many subsystems is on, and starting unused subsystems takes additional time when the system is started. 

If you want to alter the configuration of an existing subsystem you can either

The GUI tool can also be used to edit individual runlevels for a subsystem.

Subsystem configuration vs. subsystem state

Note that the configuration of a subsystem  is distinct from its current state. Using chkconfig does not have any effect until the runlevel is changed. If you want to start or stop a subsystem use the service command. Starting or stopping a current subsystem can also be accomplished using the system-config-services GUI tool.


Preview question: You have a set of commands that need to be run at the end of the boot process for every multiuser runlevel. What is the easiest way to configure this?

Prev This page was made entirely with free software on linux:  
the Mozilla Project
and Openoffice.org      
Next

Copyright 2012 Greg Boyd - All Rights Reserved.