Unix How To: The Linux /etc/inittab file

By  

One of the files that the average Unix sysadmin rarely looks at, almost never changes and yet depends on every time he or she reboots a system is the /etc/inittab file. This modest little file controls what happens whenever a system is rebooted or forced to change run levels. Let's take a look at the configuration lines that tell your system what it's supposed to do when you hit that power button.

NOTE: The /etc/inittab files on Solaris and other Unix systems that share this way of booting follow the same general rules and most of what is described below applies equally well to those Unix variants.

To begin with, the /etc/inittab file usually starts out with a block of comments describing the content of the file or giving credit like the lines shown below.

#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, 
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

Your /etc/inittab file might contain descriptions of the different run states that the system can assume. For those of you unfamiliar with this concept, a run state is basically a way to describe what is running on the system when that state is achieved. For example, run state 3 is "full multiuser mode" for most Unix systems and will have users logging in and all the expected system services running to support their use of the system.

Here's a sample of this section of the /etc/inittab file. Notice how it defines each run level for the sysadmin.

# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#

One of the most critical lines in the /etc/inittab file is the one that defines the default run level -- that is the run level that will be assumed whenever you boot the system without specifying an alternate boot level. For most Unix systems, the default run state is 3 as shown below.

id:3:initdefault:

Since this "initdefault" line contains "3" as the second field, run state 3 is the default.

Another important line on Linux systems is the sysinit line shown below. This tells the system to run the /etc/rc.d/rc.sysinit script when the system is booted.

# System initialization.
si::sysinit:/etc/rc.d/rc.sysinit

Once the system has run rc.sysinit and knows the run state that it is expected to achieve on bootup, it will select the appropriate line from the list below and run the /etc/rc.d/rc script with the argument appropriate to the run level specified.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Operating SystemsWhite Papers & Webcasts

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question