-->

Previous | Table of Contents | Next

Page 41

Whew! That's a lot of work just for the first startup script! But it's just the first step in a number of steps needed to start your system. So far, you've seen that after the Linux kernel is loaded, the init command is run. After the rc.sysinit is run by init, then init runs rc.local. If you look at the Red Hat Linux rc.local script, you'll see that it gets the operating system name and architecture of your computer and puts it into a file called /etc/issue, which is later used for display at the login prompt.

The next task of init is to run the scripts for each runlevel. If you look at the listing of the rc.d directory, you'll see the various rcX.d directories, where X is a number from 0 through 6. But if you look at the files under one of these directories, you'll find that each is merely a link to a script under init.d, with an associated name for a particular service. For example, under the rc3.d directory, you'll find


lrwxrwxrwx  1 root   root   17 Apr 10 09:11 S10network -> ../init.d/network*

lrwxrwxrwx  1 root   root   16 Apr 10 09:18 S30syslog -> ../init.d/syslog*

lrwxrwxrwx  1 root   root   19 Apr 10 09:22 S40cron -> ../init.d/cron.init*

lrwxrwxrwx  1 root   root   22 Apr 10 09:17 S40portmap -> ../init.d/portmap.init*

lrwxrwxrwx  1 root   root   16 Apr 10 09:16 S45pcmcia -> ../init.d/pcmcia*

lrwxrwxrwx  1 root   root   14 Apr 10 09:04 S50inet -> ../init.d/inet*

lrwxrwxrwx  1 root   root   20 Apr 10 09:06 S55named.init -> ../init.d/named.init*

lrwxrwxrwx  1 root   root   18 Jul 15 11:56 S60lpd.init -> ../init.d/lpd.init*

lrwxrwxrwx  1 root   root   13 Apr 10 09:16 S60nfs -> ../init.d/nfs*

lrwxrwxrwx  1 root   root   15 Apr 10 09:11 S70nfsfs -> ../init.d/nfsfs*

lrwxrwxrwx  1 root   root   18 Apr 10 09:11 S75keytable -> ../init.d/keytable*

lrwxrwxrwx  1 root   root   23 Apr 10 09:18 S80sendmail -> ../init.d/sendmail.init*

lrwxrwxrwx  1 root   root   13 Apr 10 09:10 S85gpm -> ../init.d/gpm*

lrwxrwxrwx  1 root   root   11 Apr 10 09:11 S99local -> ../rc.local*

Note the S in front of each name. This means to start a process or service. Now, if you look at the files under rc0.d, you'll see

Page 42


lrwxrwxrwx  1 root   root    18 Apr 10 09:06 K08amd ->../init.d/amd.init*

lrwxrwxrwx  1 root   root    20 Apr 10 09:06 K10named.init -> ../init.d/named.init*

lrwxrwxrwx  1 root   root    15 Apr 10 09:11 K10nfsfs -> ../init.d/nfsfs*

lrwxrwxrwx  1 root   root    13 Apr 10 09:10 K15gpm -> ../init.d/gpm*

lrwxrwxrwx  1 root   root    13 Apr 10 09:16 K20nfs -> ../init.d/nfs*

lrwxrwxrwx  1 root   root    20 Apr 10 09:06 K25httpd -> ../init.d/httpd.init*

lrwxrwxrwx  1 root   root    21 Apr 10 09:11 K25news -> /etc/rc.d/init.d/news*

lrwxrwxrwx  1 root   root    23 Apr 10 09:18 K30sendmail -> ../init.d            Âsendmail.init*

lrwxrwxrwx  1 root   root    23 Apr 10 09:14 K32mars_nwe -> ../init.d/Âmars_nwe.init*

lrwxrwxrwx  1 root   root    23 Apr 10 09:24 K33yppasswd -> ../init.d/Âyppasswd.init*

lrwxrwxrwx  1 root   root    21 Apr 10 09:24 K35ypserv -> ../init.d/ypserv.init*

lrwxrwxrwx  1 root   root    14 Apr 10 09:04 K50inet -> ../init.d/inet*

lrwxrwxrwx  1 root   root    16 Apr 10 09:16 K52pcmcia -> ../init.d/pcmcia*

lrwxrwxrwx  1 root   root    19 Apr 10 09:22 K60cron -> ../init.d/cron.init*

lrwxrwxrwx  1 root   root    18 Jul 15 11:56 K60lpd.init -> ../init.d/lpd.init*

lrwxrwxrwx  1 root   root    22 Apr 10 09:17 K65portmap -> ../init.d/portmap.init*

lrwxrwxrwx  1 root   root    16 Apr 10 09:18 K70syslog -> ../init.d/syslog*

lrwxrwxrwx  1 root   root    16 Apr 10 09:11 K80random -> ../init.d/random*

lrwxrwxrwx  1 root   root    17 Apr 10 09:11 K99killall -> ../init.d/killall*

lrwxrwxrwx  1 root   root    14 Apr 10 09:11 S00halt -> ../init.d/halt*

Notice the K in front of each name. This means to kill a process or service. If you look under each of the different rcX.d directories, you'll see what services or processes are started or stopped in each runlevel. Later in this chapter I'll come back to some of the rc.sysinit tasks because some of the error-checking done when starting up can help pinpoint problems with your system. For now, however, the following sections explain the different runlevels and what basically happens in each.

Runlevel 0: /etc/rc.d/rc0.d

As you can see from the previous directory listing, this runlevel starts the shutdown sequence. Each script is run in the order listed. Some of the tasks run include

As shown in this section, and discussed later in this chapter, there are some important things done during a shutdown involving your computer, its services, and its filesystems. Although Linux is a robust operating system with system-checking safeguards, executing a proper shutdown is essential to maintaining the integrity of your computer's hard drive as well as any Linux volumes or partitions.

Runlevel 1: /etc/rc.d/rc1.d

This is the single-user mode, or administrative state, traditionally used by system administrators, or sysadmins, while performing software maintenance. No one else can log in during this mode, and networking is turned off, although filesystems are mounted.

Page 43

Runlevel 2: /etc/rc.d/rc2.d

This is the multiuser state. Networking is enabled, although NFS is disabled.

Runlevel 3: /etc/rc.d/rc3.d

This is the default runlevel, which is specified as the first line in /etc/inittab. Remote file sharing is enabled, along with all other desired services.

Runlevel 4: /etc/rc.d/rc4.d

This directory is empty. As in other versions of UNIX, if you want to define your own runlevel, here's where you can add the appropriate links, with directions to selectively start or stop processes.

Runlevel 5: /etc/rc.d/rc5.d

This runlevel is much the same as the default, with the exception of named, the Internet domain nameserver. This is also the runlevel entered when running X11 under Linux.

Runlevel 6: /etc/rc.d/rc6.d

This is the reboot runlevel. The contents of this directory contain links similar to those in runlevel 0, but logic in the halt script under init.d determines whether or not the system is being shutdown or rebooted.

Keeping track of which process is started or stopped in which runlevel can be difficult. In the next section, you'll see one more reason why using Red Hat Linux can make your system administration tasks easier.

tksysv and Managing Your Services

One of the great things about Red Hat Linux is the number of tools included in the distribution to help you manage your system. One such handy tool is Donnie Barnes's tksysv, which can be called from a command line in a terminal window while you're running X, or through the control-panel client. You should use it for a number of reasons.

It is not only important to know how to properly shut down your system; you should also know how to properly start and stop services under Linux while the system is running. Although you can selectively "kill" processes with


# kill -9 pid

where pid is the number of the running process, this is a crude, ineffective, and potentially harmful way to stop processes. Using the information you have learned so far, you can also use the following approach (a handy tip from the tksysv help dialog), for example, to stop the Web server, httpd:


# /etc/rc.d/init.d/httpd.init stop

Previous | Table of Contents | Next