Init Runlevels
The idea behind operating different services at different runlevels
revolves around the fact that different systems can be used
in a different ways. Some services cannot be used until the system is in
a particular state, or mode, such as ready for
more than one user or has networking available.
There are times in which you may want to operate the system at a lower
mode, such as fixing disk corruption problems in runlevel 1, when no other
users can possibly be on the system or leaving a server in runlevel 3
without an X session running. In these cases, running services that
depend upon a higher system mode to function does not make sense because
they will not work correctly anyway. By already having each service
assigned to start when its particular runlevel is reached, you ensure an
orderly start up process and can quickly change the mode of the machine
without worrying about which services to manually start or stop.
Generally, Red Hat Linux operates in runlevel 3 or runlevel 5 — both full
multi-user modes. The following runlevels are defined in Red Hat Linux:
0 — Halt
1 — Single-user mode
2 — Not used (user-definable)
3 — Full multi-user mode
4 — Not used (user-definable)
5 — Full multi-user mode (with an X-based
login screen)
6 — Reboot
The default runlevel for a system to boot into and stop is configured in
/etc/inittab. For more information on
/etc/inittab, see the Section called SysV Init.
Feel free to configure runlevels 2 and 4 as you see fit. Many users
configure those runlevels in a way that makes the most sense for them
while leaving the standard runlevels 3 and 5 alone. This allows them to
quickly move in and out of their custom configuration without disturbing
the normal set of features at the standard runlevels.
If your machine gets into a state where it will not boot due to a bad
/etc/inittab or will not let you log in because you
have a corrupted /etc/passwd or if you have simply
forgotten your password, you can boot into single-user mode.
If you are using LILO, you can enter single-user mode by typing
linux single at the LILO boot:
prompt.
If you are using GRUB as your boot loader, you can enter single-user mode using
the following steps.
In the graphical GRUB boot loader screen, select the
Red Hat Linux boot label and press [e]
to edit it.
Arrow down to the kernel line and press [e]
to edit it.
At the prompt, type single and press
[Enter].
You will be returned to the GRUB screen with the kernel
information. Press the [b] key to boot the system
into single user mode.
A very bare system will boot, and you will have a command shell
from which you can fix things.
If this does not work, you will need to boot by typing
linux init=/bin/bash at the LILO
boot: prompt. This places you at a shell prompt; note
that no file systems other than the root file system are mounted, and the
root file system is mounted in read-only mode. To mount it in read-write
mode (to allow editing of a broken /etc/inittab, for
example) do:
mount -n /proc
mount -o rw,remount / |
Initscript Utilities
The /sbin/chkconfig utility is a simple
command-line tool for maintaining the
/etc/rc.d/init.d directory hierarchy. It
relieves system administrators from having to directly manipulate the
numerous symbolic links in the directories under
/etc/rc.d.
In addition, there is /sbin/ntsysv that provides a
text-based interface, which you may find easier to use than
chkconfig's command-line interface.
If you prefer a graphical interface, use the
Services Configuration Tool program, which can be
invoked using the redhat-config-services command.
All of these utilities must be run as root.
Please refer to the chapter titled Controlling Access to
Services in Official Red Hat Linux Customization Guide for more
information regarding these tools.
Next, we will discuss information in the files within the
/etc/sysconfig/ directory which define the
parameters used by some services when they start up.