Understanding init

  • Init process is the mother (parent) of all processes on the system. It is the first program that is executed when Linux boots up.
  • Init processes manages all other processes on the system.
  • Init process is started by the kernel itself which means init does not have parent process.
  • Init process always have process ID (PID) of 1.

Once the kernel is loaded it will look for init process. The init stands for initialization process, which means a process that starts other processes and services. A service is a program that performs particular duty on a system. The system will look for init process in /sbin/init file, and this file is usually a symbolic link to three types of init processes: SysV, upstart or systemd. They were developed to make loading system configuration more efficiently. The init process (SysV, upstart or systemd) are responsible for starting user space environment and in this point we are moving on to user space from kernel space environment.

When init loads user space environment, broadly these steps are happening:

  1. Low-level services are loaded such as udevd, syslog, file system mounts…
  2. Network configuration files are loaded
  3. High-level services are loaded such as httpd, cron, nginx,…
  4. Login prompt is shown

There are two ways in which services are loaded:

  1. Serial loading – it starts first service, then second service, then third service and so on…
  2. Parallel loading – it starts multiple services at the same time, then multiple other services in parallel, and so on (much efficient way to start services)

All service startups are handled by init program. This program can be located in /etc/, /bin/ or /sbin/ directory. The init process ID (PID) is always 1. To find location of init program use which command, like so:

[aldin@arch ~]$ which init
/usr/bin/init

Now that we know location of init, use readlink to see if the /usr/bin/init points to another program (systemd or upstart for example):

[aldin@arch ~]$ readlink -f /usr/bin/init
/usr/lib/systemd/systemd

In my example, the initialization process for my system is systemd. Also, check to which program PID 1 points to with ps command:

[aldin@arch ~]$ ps -p 1
    PID TTY          TIME CMD
      1 ?        00:00:00 systemd

Leave a Reply