Kernel
The kernel creates a process with process id 0 which eventually gets converted into the swapper process. The kernel then optionally runs the initrd (which stands for init RAM disk) which is a temporary filsystem in the the RAM for kernel unil the filesystem on the hard-disk in initialised.
The process 0 would then invoke the init
process (usually located in /sbin/init)
Init
All the processes are invoked directy or indirectly by the init
process (with the exceptio of pager
process.) init
process has the process id of 1. The init
when started will take care of the following things:
/etc/inittab
file. The inittab file is a configuration file and contains entries where each entry is a line of the following formatid:runlevels:action:process
id
runlevels
action
process
inittab
file would be with initdefault
action in order to set the runlevel for the system. It would normally look something lke the following id:5:initdefault:
inidefault
will cause the system to boot with different capabilities. Following are the general capabilities configured with different runlevels.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
The rc process gets told about the run-level via the command line argument and it runs the scripts in the directory specific to that run-level. Each run-level has its own directory where several scripts are placed. Some of the scripts are executed at startup while some of them are executed at shutdown time. Start up scripts start with 'S' and shutdown scripts start with 'K'.1:2345:respawn:/sbin/mingetty tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4
e.g. the above four lines specify the system to spawn four tty consoles. TTY console are normally the console screens that display the characters. It is typical to find more than one consoles configured for a single system even if there is only one monitor connected to the system. Second console can be accessed by pressing CTRL+ALT+2
. Similarly third console can be accessed by pressing CTRL+ALT+3
.init
will spawn getty processes (by doing a fork and exec). getty initalizes itself, displays the login prompt and then requests for the username.login
.login
program will call the getpass
program to input and validate the password. If getpass
fails validation, login
program will exit. This will be noticed by init and it will do another fork because the entry for getty in the inittab file had respawn actiongetpass
program succeeds, then login will proceed to log-in the user by doing the following/etc/passwd
file)/etc/passwd
file for the user