/etc/inittab

The /etc/inittab file is the configuration file used by the System V (SysV) initialization system in Linux. This file defines three items for the init process:

  • the default runlevel
  • what processes to start, monitor, and restart if they terminate
  • what actions to take when the system enters a new runlevel

Once all the entries in /etc/inittab for your runlevel are executed, the boot process is completed, and you can log in.

Each line in the inittab file consists of four colon-delimited fields:

id:runlevels:action:process

Here is a description of these fields:

  • id (identification code) – consists of a sequence of one to four characters that identifies its function.
  • runlevels – lists the run levels to which this entry applies.
  • action – specific codes in this field tell init how to treat the process. Possible values include: initdefault, sysinit, boot, bootwait, wait, and respawn.
  • process – defines the command or script to execute.

Consider the following example:

linux inittab runlevels

In the picture above you can see that the runlevels are defined as:

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
#l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6

The lines start with codes that begin with an l (a lowercase L) followed by the runlevel number—for instance, l0 for runlevel 0. These lines specify scripts or programs that will be run when the specified runlevel is entered. In our case, all the scripts are the same (/etc/init.d/rc), but the script is passed the runlevel number as an argument.

Geek University 2022