Red Hat Linux 7.3: The Official Red Hat Linux Reference Guide | ||
---|---|---|
Prev | Chapter 3. Boot Process, Init, and Shutdown | Next |
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), 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
Arrow down to the kernel line and press
At the prompt, type single and press
You will be returned to the GRUB screen with the kernel
information. Press the
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 filesystems other than the root filesystem are mounted, and the root filesystem 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 / |
The chkconfig utility in /sbin provides 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 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 serviceconf program.
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.