previous contents up next

Unix for Advanced Users

9. The Unix Boot Sequence

9.5. Starting init

init is the last process created at boot time. It always has a process ID (PID) of 1 (i.e. on all Unixes). init is responsible for starting all subsequent processes. Consequently, it is the parent (in other words, mother of all processes!) of all (non-dummy) Unix processes.

The init Command: Don't confuse the init process with the system init command. The init command (usually found in /sbin or /usr/sbin) is used by root to put the system into a specific run level (run levels are described next).

Run Levels: Each Unix vendor defines a number of arbitrary run levels which correspond to a certain system state (such as single or multiuser mode). When the system is in a certain run level, only a specified group of system processes can exist. For example, under Linux RedHat 6.0, the default convention is:

   0 - Halt
   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 (run a graphical login window)
   6 - Reboot
(So, for example, running "init 6" as root under Linux will reboot the system.)

The set of processes which are allowed to exist under a certain run level are started by init during the boot sequence via the /etc/inittab file.

/etc/inittab: On most Unixes, init reads a configuration file called /etc/inittab which tells init how to start the processes necessary to bring the system up to a default run level (usually the multiuser mode).

Here is a typical /etc/inittab (from a system running Linux RedHat 6.0):

################################################################################
# 
# inittab for Linux
#
id:5:initdefault:

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

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

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

# Trap CTRL-ALT-DELETE
ca::ctrlaltdel:/sbin/shutdown -t3 -r now           # Run gettys 
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6

# Run xdm in runlevel 5
# xdm is now a separate service
x:5:respawn:/etc/X11/prefdm -nodaemon       
#################################################################################
The general format of this file is where "id" is a unique sequence of characters which identifies the inittab entry, "runlevels" lists the run levels for which the specified action is to be taken, "action" describes the action to be taken, and "process" describes the exact process which is to be executed.

In the example above, the first entry, namely "id", tells init is that the default system run level is 5 (i.e. that init should leave the system at this run level after boot).

Exercise: Log on to sunedsrv, hped1, or sgied1 as edcert and look at the /etc/inittab on these other Unixes.

telinit: The command "telinit q" causes init to reread /etc/inittab.

previous contents up next