All Red Hat Linux documents are copyrighted to Red Hat Inc.

1.4. SysV Init Runlevels

The SysV init runlevel system provides a standard process for controlling which programs init launches or halts when initializing a runlevel. SysV init was chosen because it is easier to use and more flexible than the traditional BSD-style init process.

The configuration files for SysV init are located in the /etc/rc.d/ directory. Within this directory, are the rc, rc.local, rc.sysinit, and, optionally, the rc.serial scripts as well as the following directories:

init.d/
rc0.d/
rc1.d/
rc2.d/
rc3.d/
rc4.d/
rc5.d/
rc6.d/

The init.d/ directory contains the scripts used by the /sbin/init command when controlling services. Each of the numbered directories represent the six default runlevels configured by default under Red Hat Linux.

1.4.1. Runlevels

Runlevels are a state, or mode, defined by the services listed in the SysV /etc/rc.d/rc<x>.d/ directory, where <x> is the number of the runlevel.

The idea behind SysV init runlevels revolves around the fact that different systems can be used in a different ways. For example, a server runs more efficiently without the drag on system resources created by the X Window System. Other times, a system administrator may need to operate the system at a lower runlevel to perform diagnostic tasks, like fixing disk corruption in runlevel 1, when no other users can possibly be on the system.

The characteristics of a given runlevel determines which services are halted and started by init. For instance, runlevel 1 (single user mode) halts any network services, while runlevel 3 starts these services. By assigning specific services to be halted or started on a given runlevel, init can quickly change the mode of the machine without the user manually stopping and starting services.

The following runlevels are defined by default for Red Hat Linux:

  • 0 — Halt

  • 1 — Single-user text mode

  • 2 — Not used (user-definable)

  • 3 — Full multi-user text mode

  • 4 — Not used (user-definable)

  • 5 — Full multi-user graphical mode (with an X-based login screen)

  • 6 — Reboot

In general, users operate Red Hat Linux at runlevel 3 or runlevel 5 — both full multi-user modes. Users sometimes customize runlevels 2 and 4 to meet specific needs. since they are not used.

The default runlevel for the system is listed in /etc/inittab. To find out the default runlevel for a system, look for the line similar to the one below near the top of /etc/inittab:

id:5:initdefault:

The default runlevel listed in the example above is five, as the number after the first colon indicates. To change it, edit /etc/inittab as root.

WarningWarning
 

Be very careful when editing /etc/inittab. Simple typos can cause the system to become unbootable. If this happens, either use a boot diskette, enter single-user mode, or enter rescue mode to boot the computer and repair the file.

For more information on single-user and rescue mode, see the chapter titled Rescue Mode in the Red Hat Linux Customization Guide.

It is possible to change the default runlevel at boot-time by modifying the arguments passed by the boot loader to the kernel. For information on changing the runlevel at boot time, see Section 2.10 Changing Runlevels at Boot Time.

1.4.2. Runlevel Utilities

One of the best ways to configure runlevels is to use an initscript utility. These tools are designed to simplify the task of maintaining files in the SysV init directory hierarchy and relieves system administrators from having to directly manipulate the numerous symbolic links in the subdirectories of /etc/rc.d/.

Red Hat Linux provides three such utilities:

  • /sbin/chkconfig — The /sbin/chkconfig utility is a simple command-line tool for maintaining the /etc/rc.d/init.d directory hierarchy.

  • /sbin/ntsysv — The ncurses-based /sbin/ntsysv utility provides an interactive text-based interface, which some find easier to use than chkconfig.

  • Services Configuration Tool — The graphical Services Configuration Tool (redhat-config-services) program is a flexible GTK2-based utility for configuring runlevels.

Please refer to the chapter titled Controlling Access to Services in Red Hat Linux Customization Guide for more information regarding these tools.

© Copyright 2003-2014 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.