Previous Section
 < Day Day Up > 
Next Section


SysV Init: init.d Scripts

You can manage the startup and shutdown of server daemons with special startup scripts located in the /etc/rc.d/init.d directory. These scripts often have the same name as the server's program. For example, for the /usr/sbin/httpd Web server program, the corresponding script is called /etc/rc.d/init.d/httpd. This script starts and stops the Web server. This method of using init.d startup scripts to start servers is called SysV Init, after the method used in Unix System V.

Tip 

If you change the configuration of a server, you may need to start and stop it several times as you refine the configuration. Several servers provide special management tools that enable you to perform this task easily. The apachectl utility enables you to start and stop the Apache Web server easily. It is functionally equivalent to using the /etc/rc.d/init.d/httpd script to start and stop the server. For the domain name server, the ndc utility enables you to start and stop the named server. However, it is not advisable to mix the use of init.d scripts and the management tools.

The startup scripts in the /etc/rc.d/init.d directory can be executed automatically whenever you boot your system. Be careful when accessing these scripts, however. These start essential programs, such as your network interface and your printer daemon. These init scripts are accessed from links in subdirectories set up for each possible runlevel. The /etc/rc.d directory holds a set of subdirectories whose names have the format rcN.d, where N is a number referring to a runlevel. The rc script detects the runlevel in which the system was started, and then executes only the startup scripts specified in the subdirectory for that runlevel. When you start your system, the rc script executes the startup scripts specified in the rc3.d directory, if you are performing a command line login, and the rc5.d directory, if you are using a graphical login. The rc3.d and rc5.d directories hold symbolic links to certain startup scripts in the /etc/rc.d/init.d directory. So, the httpd script in the /etc/rc.d/init.d directory is actually called through a symbolic link in the rc3.d or the rc5.d directory. The symbolic link for the /etc/rc.d/httpd script in the rc3.d directory is S85httpd. The S prefixing the link stands for "startup"; thus, the link calls the corresponding init.d script with the start option. The number indicates the order in which startup scripts are run; lower numbers run first. S85httpd invokes /etc/rc.d/init.d/httpd with the option start. If you change the name of the link to start with a K, the script is invoked with the stop option, stopping it. Such links are used in the runlevels 0 and 6 directories, rc6.d and rc0.d. Runlevel 0 halts the system and runlevel 6 reboots it. You can use the runlevel command to find out what runlevel you are currently operating at (see Chapter 27 for more details on runlevels). A listing of runlevels is shown in Table 20-2.

Table 20-2: System Runlevels

Runlevel

rc.d Directory

Description

0

rc0.d

Halt (shut down) the system

1

rc1.d

Single-user mode (no networking, limited capabilities)

2

rc2.d

Multiuser mode with no NFS support (limited capabilities)

3

rc3.d

Multiuser mode (full operational mode)

4

rc4.d

User-defined, implemented by default on Red Hat the same as runlevel 3, multiuser mode

5

rc5.d

Multiuser mode with graphical login (full operation mode with graphical login added)

6

rc6.d

Reboot system



Previous Section
 < Day Day Up > 
Next Section
This HTML Help has been published using the chm2web software.