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 being ready for more than one user or having 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 startup 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 in is configured in /etc/inittab. For more information on /etc/inittab, see the “Init Runlevels” section of this chapter. 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 because of 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.

  1. In the graphical GRUB boot loader screen, select the Red Hat Linux boot label and type e to edit it.

  2. Arrow down to the kernel line and type e to edit it.

  3. At the prompt, type single and press Enter.

  4. You will be returned to the GRUB screen with the kernel information. Type b to boot the system into single-user mode.

  5. 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 of having to directly manipulate the numerous symbolic links in the directories under /etc/rc.d. In addition, there is /sbin/ntsysv, which provides a text-based interface that 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.

Cross-Reference

See Chapter 21 for more information regarding these tools.

Next, we will discuss information in the files within the /etc/sysconfig/ directory that define the parameters used by some services when they start up.




Official Red Hat Linux Administrator's Guide
Official Red Hat Linux Administrators Guide
ISBN: 0764516957
EAN: 2147483647
Year: 2002
Pages: 278
Authors: Red Hat Inc

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net