Sunday, 9 February 2014

All About "inittab" File

inittab File

Purpose :Controls the initialization process.


The /etc/inittab file supplies the script to the init command's role as a general process dispatcher. The process that constitutes the majority of the init command's process dispatching activities is the /etc/getty line process, which initiates individual terminal lines. Other processes typically dispatched by the init command are daemons and the shell.
The /etc/inittab file is composed of entries that are position-dependent and have the following format:
Note: The colon character (:)is used as a delimiter as well as a comment character. To comment out an inittab entry, add : at the beginning of the entry. For example:
Each entry is delimited by a newline character. A backslash (\) preceding a newline character indicates the continuation of an entry. There are no limits (other than maximum entry size) on the number of entries in the /etc/inittab file. The maximum entry size is 1024 characters. The entry fields are:

Options Elaboration
A string (one or more than one character) that uniquely identifies an object.
The run level in which this entry can be processed. Run levels effectively correspond to a configuration of processes in the system. Each process started by the init command is assigned one or more run levels in which it can exist. Run levels are represented by the numbers 0 through 9. For example, if the system is in run level 1, only those entries with a 1 in the runlevel field are started. When you request the init command to change run levels, all processes without an entry in the runlevel field for the target run level receive a warning signal (SIGTERM). There is a 20-second grace period before processes are forcibly terminated by the kill signal (SIGKILL). The runlevel field can define multiple run levels for a process by selecting more than one run level in any combination from 0 through 9. If no run level is specified, the process is assumed to be valid at all run levels.
There are three other values that appear in the runlevel field, even though they are not true run levels: ab, and c. Entries that have these characters in the runlevel field are processed only when the telinit command requests them to be run (regardless of the current run level of the system). They differ from run levels in that the init command can never enter run level ab, or c. Also, a request for the execution of any of these processes does not change the current run level. Furthermore, a process started by an a,b, or c command is not killed when the init command changes levels. They are only killed if their line in the /etc/inittab file is marked off in the action field, their line is deleted entirely from /etc/inittab, or the init command goes into single-user mode.
start of change Tells the init command how to treat the process specified in the identifier field. The following actions are recognized by the initcommand:
If the process does not exist, start the process. Do not wait for its termination (continue scanning the /etc/inittab file). Restart the process when it dies. If the process exists, do nothing and continue scanning the /etc/inittab file.
When the init command enters the run level that matches the entry's run level, start the process and wait for its termination. All subsequent reads of the /etc/inittab file while the init command is in the same run level will cause the init command to ignore this entry.
When the init command enters a run level that matches the entry's run level, start the process, and do not wait for its termination. When it dies, do not restart the process. When the system enters a new run level, and the process is still running from a previous run level change, the program will not be restarted. All subsequent reads of the /etc/inittab file while the initcommand is in the same run level will cause the init command to ignore this entry.
Process the entry only during system boot, which is when the init command reads the /etc/inittab file during system startup. Start the process, do not wait for its termination, and when it dies, do not restart the process. In order for the instruction to be meaningful, the run level should be the default or it must match the init command's run level at boot time. This action is useful for an initialization function following a hardware reboot of the system.
Process the entry the first time that the init command goes from single-user to multi-user state after the system is booted. Start the process, wait for its termination, and when it dies, do not restart the process. If the initdefault is 2, run the process right after boot.
Execute the process associated with this entry only when the init command receives a power fail signal (SIGPWR).
Execute the process associated with this entry only when the init command receives a power fail signal (SIGPWR), and wait until it terminates before continuing to process the /etc/inittab file.
If the process associated with this entry is currently running, send the warning signal (SIGTERM), and wait 20 seconds before terminating the process with the kill signal (SIGKILL). If the process is not running, ignore this entry.
Functionally identical to respawn, except this action applies to the a, b, or c values, not to run levels.
An entry with this action is only scanned when the init command is initially invoked. The init command uses this entry, if it exists, to determine which run level to enter initially. It does this by taking the highest run level specified in the runlevel field and using that as its initial state. If the runlevel field is empty, this is interpreted as 0123456789; therefore, the init command enters run level 9. Additionally, if the init command does not find an initdefault entry in the /etc/inittab file, it requests an initial run level from the user at boot time.
Entries of this type are executed before the init command tries to access the console before login. It is expected that this entry will only be used to initialize devices on which the init command might try to ask the run level question. These entries are executed and waited for before continuing.
end of change
A shell command to execute. The entire command field is prefixed with exec and passed to a forked sh as sh -c exec command. Any legal sh syntax can appear in this field. Comments can be inserted with the  # comment syntax.
The getty command writes over the output of any commands that appear before it in the inittab file. To record the output of these commands to the boot log, pipe their output to the alog -tboot command.
The stdin, stdout and stdferr file descriptors may not be available while init is processing inittab entries. Any entries writing to stdout or stderr may not work predictably unless they redirect their output to a file or to /dev/console.

Commmands Exploration

The following commands are the only supported method for modifying the records in the /etc/inittab file:
mkitabAdds records to the  /etc/inittab file.
lsitabLists records in the  /etc/inittab file.
chitabChanges records in the  /etc/inittab file.
rmitabRemoves records from the  /etc/inittab file.
telinitTo re-read/ re-examine /etc/inittab file.


will add new record (entry) in /etc/inittab.
mkitab [ -i Identifier ] { [ Identifier ] : [ RunLevel ] : [ Action ] : [ Command ] }

1) To add a new record to the /etc/inittab file, telling the init command to handle start of cdrom deamon, type:

   # mkitab “cdrom:2:respawn:startsrc –d cdromd”

2) To add a new record to the /etc/inittab file, telling the init command to execute the /etc/rc.tcpip file after the /usr/sbin/srcmstr file is started, type:

   # mkitab -i srcmstr "rctcpip:2:wait:/etc/rc.tcpip > /dev/console"

3) To add a new record to the /etc/inittab file, telling the init command to execute the /etc/rc file and send its output to the boot log, type:

   # mkitab ((rc:2:wait:/etc/rc 2>&1 | alog -tboot > /dev/console))


will list the records available in /etc/inittab
lsitab { -a | Identifier }

  1. To display the record for cdrom, enter:

    # lsitab "cdrom"

    The output is similar to: cdrom:3:respawn:startsrc –s cdromd

  2. To display all of the records in the /etc/inittab file, enter:

    # lsitab -a

    All of the records in the /etc/inittab file are displayed.


To change a record in /etc/inittabfile
chitab { Identifier: RunLevel : Action : Command }

Note: The chitab command can not comment out an entry in the /etc/inittab file.

1) To change the record cdrom action to once enter:

# chitab “cdrom:2:once:startsrc –s cdromd”

2) To change the run level of a record for tty2, enter:

# chitab "tty002:23:respawn:/usr/sbin/getty /dev/tty"

The quotes are required when the record being added has spaces or tabs.

rmitab :

To remove the records from /etc/inittab
rmitab { Identifier }

1) To remove the record "cdrom" from /etc/inittab enter

# rmitab “cdrom"

telnit :

The telinit command initializes and controls processes. Its primary role is to start processes based on records read from the /etc/inittab file.Whenever you make any changes to /etc/inittab file you can ask the system to re-read the file using telinit.So always try to couple "telinit" with "chitab"
{ telinit | init } { 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | h | Q | q | S | s | M | m | N }

  1. To request the init command to reexamine the /etc/inittab file, enter:

    telinit  q

  2. To request the init command to enter maintenance mode, enter:

    telinit  s

Few Miscellaneous Examples

  1. To start the ident process at all run levels, enter:
  2. To start the ident process only at run level 2, enter:
  3. To disable run levels 0, 3, 6-9 for the ident process, enter:
  4. To start the rc command at run level 2 and send its output to the boot log, enter:
    rc:2:wait:/etc/rc 2>&1 | alog -tboot > /dev/console

0 blogger-disqus:

Post a Comment