SysV Startup Script Locations and Names

SysV startup scripts work in runlevels, which are numbered sets of servers and other important system components. Runlevel 0 shuts down the computer, runlevel 1 is a special single-user mode that can be used for emergency maintenance, and runlevel 6 reboots the computer. Runlevels 2 through 5 can be configured as you see fit. Most Linux distributions use runlevel 3 as a standard text-mode startup and runlevel 5 to start X and an X Display Manager Control Protocol (XDMCP) GUI login screen. Debian, though, attempts to start X and an XDMCP server in all runlevels between 2 and 5; and Slackware uses runlevel 4 rather than runlevel 5 to start X and an XDMCP server.

In order to implement runlevels, most Linux distributions place SysV startup scripts in one directory and then create symbolic links to these scripts in other directories named after the runlevel in question. Table 22.1 summarizes these locations. A question mark (?) in a directory name stands for a runlevel number between 0 and 6. Debian and SuSE also support an S in this position, which is used for startup scripts—servers that should run in all runlevels. In addition to these directories, some distributions create symbolic links. For instance, SuSE creates a link called /etc/rc.d that points to /etc/init.d, and Mandrake and Red Hat create links called /etc/init.d that point to /etc/rc.d/init.d. This practice can help you if you type a path to a script that's valid on one distribution but that might not work on the one you're using.

Table 22.1 : SysV Startup Script Locations

Distribution

SysV Startup Script Main Directory

SysV Startup Script Link Directories

Debian 3.0

/etc/init.d

/etc/rc?.d

Mandrake 9.1

/etc/rc.d/init.d/

/etc/rc.d/rc?.d

Red Hat 9.0

/etc/rc.d/init.d/

/etc/rc.d/rc?.d

SuSE 8.1

/etc/init.d

/etc/init.d/rc?.d

Note Slackware doesn't use SysV startup scripts in the same way as do most other distributions, but it does use runlevels. Instead of using SysV startup scripts as described here, Slackware uses startup scripts called /etc/rc.d/rc?.d, where ? is the runlevel number, to set the runlevel.

Within the main startup script directory, SysV startup scripts are typically named after the servers or other programs they launch. For instance, on a Debian system, apache starts the Apache web server, exim starts the Exim mail server, and samba starts the Samba file server. These names aren't completely standardized across distributions, though. For instance, Mandrake, Red Hat, and SuSE all use smb rather than samba to start Samba. Also, distributions sometimes use different servers for the same function. For instance, Debian uses Exim as a mail server, Mandrake and SuSE use Postfix (started with a postfix SysV startup script), and Red Hat and Slackware use sendmail (started with a sendmail SysV startup script in the case of Red Hat). You can override these defaults by removing the standard package and installing another one. You can also add and remove servers; most server packages ship with one or more SysV startup scripts. For all of these reasons, the contents of the main SysV startup script directories vary a great deal from one distribution or installation to another.

Warning Installing a package intended for one distribution on another distribution often works without problems. SysV startup scripts, though, tend to be very distribution-specific, which complicates their installation across distributions. If you must do this, you may need to remove the SysV startup script that came with the package and create a new one or bypass the SysV startup procedure and use local startup scripts. Chapter 9 describes how to create a new SysV or local startup script.

The SysV startup script link directories contain symbolic links to the original SysV startup scripts. These links are named after the original scripts, but they begin with three new characters: an S or a K and a two-digit number. For instance, a link might be called S91 apache and link to the main apache startup script. The leading S or K characters stand for start or kill, respectively—they're codes for whether the server should or should not run in the specified runlevel. The two-digit number is a sequence code. Scripts are executed in the sequence specified by those numbers. You can use this feature to control the order in which servers run. For instance, Apache is a high-level server that relies on other features, such as basic networking. For this reason, it has a high number. Unfortunately, sequence numbers aren't standardized across distributions, so if you're used to one distribution and must work on another, you may find the sequence numbers unfamiliar.

0 0

Post a comment