sections in this module | City
College of San Francisco - CS260A Unix/Linux System Administration Module: StartupShutdown I |
module list |
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.dHere, 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:
chkconfig may be
used to add or delete the configuration of a subsystem. It may
also be used to change the runlevels that a subsystem is
configured to be started at. (A similar tool ntsysv can also be
used.)
a GUI control panel system-config-services provides a GUI interface to chkconfig.
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 chkconfigchkconfig --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
use chkconfig --level to temporarily alter its configuration or
edit the default configuration, then use chkconfig --del followed by chkconfig --add to install it.
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 |