There are seven runlevels numbered 0 through 6, five of which have fairly well-defined uses:
On our system, runlevels 3 through 5 are identical and runlevel 2 does not include networking or gpm.
The services which are run for each runlevel are specified in directories /etc/rc.d/rc#.d/, where "#" is the runlevel. The "files" in the runlevel directory are symbolic links to scripts in /etc/rc.d/init.d. The names are of the form "Snndaemon" or "Knndaemon", where S means start this daemon in this runlevel, and K means kill this daemon before starting this runlevel, and nn is a number used to order the kills and starts. When a runlevel is started, the kill scripts are run in alphabetical order, and then the start scripts are run, also in alphabetical order.
When booting, init first runs the scripts in /etc/rc.d/rcsysinit.d. For our system, these:
init then runs the scripts for the specific runlevel as described above. For instance, in runlevel 3, they:
The above init strategy makes it particularly easy to restart services: one simply re-runs the script. For example, to change the IP address, the system administrator need only modify the correct configuration files and run "/etc/rc.d/init.d/network restart". Rebooting should never be necessary, except if a different kernel needs to be run, an extremely rare kernel panic occurs, or a power failure occurs.
System administrators often put all of their local modifications in a single script, which is usually run just before init starts the agetty processes. To do this, one could create the script /etc/rc.d/init.d/local and then link it to the appropriate run level directories using, for instance, "ln -s /etc/rc.d/init.d/local /etc/rc.d/rc3.d/S99local". If you really want lpr to be started before the local script, simply rename its link to S98lprng using the mv command.
Windows uses the "registry" to hold configuration information, but it is nearly impossible to modify it in a "safe" way other than through control panels which do much to hide the workings of the system from the curious. Registry failure is generally a catastrophic event, while text file failure only affects the particular file involved.
When booting from the DVD-ROM, our distribution interactively prompted you to configure the following files (from /etc/rc.d/init.d/configure):
(your host's IP address) (your host's full domain name) (your host's alias)
127.0.0.1 localhost
nameserver (your DNS server's IP address)
HOSTNAME=(your host's full domain name)Notice that the contents of this file (as well as the one following and many other configuration files in a UNIX environment) resemble shell commands used to set environment variables; that is exactly what they are (they are included in startup scripts at run time);
Note that systems with two or more NICs can behave oddly. Depending on timing considerations (which are not always consistent) and whether you have booted cold or warm (from power off or via a reboot command), the identity of your NICs may change! For instance, what was eth0 on a cold boot may become eth1 on a reboot, and vise versa. If this becomes a problem, it can be controlled by building the drivers as modules (see week 10) and loading them in a specific order at startup time.Minimal contents of the ipv4 file are:
SERVICE=ipv4-staticThis is a good place to remind you that Unix is case-sensitive!
IP=(the IP address for eth0)
PREFIX=(the number of bits in the network portion of the IP address for eth0)
GATEWAY=(your gateway's IP address)
BROADCAST=(the broadcast address for eth0)
ONBOOT=yes
A common technique is to use symbolic links for devices for increased flexibility. For instance, you could link /dev/flash to /dev/sdb1 with "ln -s /dev/sdb1 /dev/flash" and change the /media/usbstg line's device entry from /dev/sdb1 to /dev/flash. By using a symbolic link in fstab instead of a specific device, changes in hardware configuration will not require another change in fstab (or in any scripts); simply delete the old /dev/flash link and make a new one as appropriate. Other common links are /dev/cdrom and /dev/dvd.
©2007, Kenneth R. Koehler. All Rights Reserved. This document may be freely reproduced provided that this copyright notice is included.
Please send comments or suggestions to the author.