Sunday, October 9, 2016

SysVinit

The flow chart to explain how Linux PC is started

PC gets powered on
BIOS/UEFI
Boot loader
Kernel
init or systemd

SysVinit (System Five Init) has been main stream for Unix OS so far. But recently, "systemd" is getting more popular for Linux to boot its system. Now the certificate LPIC requires both knowledge of systemd and SysVinit.

In Linux system, the process "init", which is firstly executed in the system, starts necessary services serially following the setting file locating at /etc/inittab. The flow will be as follows:

1, init reads /etc/inittab file.
2, init reads /etc/rc.sysinit script.
3, init executes /etc/rc script.
4, This /etc/rc script executes the scripts locating under /etc/rc<runlevel>.d

But in case your system is not using SysVinit, which was a main stream before, there might not be /etc/inittab file. Even if the file exists, if the system is not usnig SysVinit, the file etc/inittab can be blank.

SysVinit uses scripts locating under /etc/rc<runlevel>.d to start services needed for each runlevel. For example, /etc/rc3.d directory has script files used for runlevel 3. These can be seen by using the following command:

$ ls /etc/rc3.d

These scripts stored at /etc/rc3.d is used to start, for example, servers, system services, or to restart the PC. If you want to use httpd service for example, use a command as follows:

# /etc/init.d/httpd start

To stop the httpd, use a command as follows:

# /etc/init.d/httpd stop