Linux Init Program

Posted: September 24, 2010 in Uncategorized
The init program is the first program run after your kernel begins running. It is configured with the /etc/inittab file. By modifying your /etc/inittab file, you change your system configuration in the following areas:

  1. Start up system run level.
  2. Specify processes to be executed during system boot.
  3. Specify processes to be run when the specified runlevel is entered.
  4. Specify processes to be run on certain runlevels with actions like respawn so the process is restarted any time it terminates.
  5. Specify certain actions or processes to be run if certain signals or user actions are indicated.

The previous section on LILO explained what runlevels are.

Below is an example inittab file with line numbers added on the left side for reference:

	# 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

	# 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)
1)	id:3:initdefault:

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

3)	l0:0:wait:/etc/rc.d/rc 0
4)	l1:1:wait:/etc/rc.d/rc 1
5)	l2:2:wait:/etc/rc.d/rc 2
6)	l3:3:wait:/etc/rc.d/rc 3
7)	l4:4:wait:/etc/rc.d/rc 4
8)	l5:5:wait:/etc/rc.d/rc 5
9)	l6:6:wait:/etc/rc.d/rc 6

	# Things to run in every runlevel.
10)	ud::once:/sbin/update

11)	ca::ctrlaltdel:/sbin/shutdown -t3 -r now

	# When our UPS tells us power has failed, assume we have a few minutes
	# of power left.  Schedule a shutdown for 2 minutes from now.
	# This does, of course, assume you have powerd installed and your
	# UPS connected and working correctly.  
12)	pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

	# If power was restored before the shutdown kicked in, cancel it.
13)	pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"

	# Run gettys in standard runlevels
14)	1:2345:respawn:/sbin/mingetty tty1
15)	2:2345:respawn:/sbin/mingetty tty2
16)	3:2345:respawn:/sbin/mingetty tty3
17)	4:2345:respawn:/sbin/mingetty tty4
18)	5:2345:respawn:/sbin/mingetty tty5
19)	6:2345:respawn:/sbin/mingetty tty6

	# Run xdm in runlevel 5
	# xdm is now a separate service
20)	x:5:respawn:/etc/X11/prefdm -nodaemon

Line number 1 sets the runlevel to 3. Line numbers 3 through 9 will run the startup script /etc/rc.d/rc for the appropriate run level as selected on line 1. Line numbers 14 through 19 spawn login getty programs on 6 virtual terminals. Other lines perform such things as power management and trapping the CTRL-ALT-DEL keystrokes for shutdown. Please see the “How Linux Works CTDP Guide” for further information on the format of the inittab file and what the init program does.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s