In this article, you will learn about the short description of the init process, the runlevels of init, and the init command in a Linux system.
What is Init Process?
In layman’s terms, when you press the power button, your system will first look for the bootloader (basically, your Linux grub), and then it will try to launch the kernel.
But the kernel itself cannot launch all of the processes, so it will start the first (or parent) process, known as init (sort for “initialization“), with PID “1” (process identifiers are assigned in sequential order).
The “/etc/inittab
” script is used by the “init” process. It has entries for processes that do basic things when the system starts up and shuts down, like showing the user a login screen with gettys, mounting and unmounting file systems, and managing daemons.
As a result, it should be kept running until the system terminates. If the kernel is unable to start it, the system will reach a stage called “Kernel Panic“.
Run Levels
Run Levels is a system software configuration (by init) that defines a set of processes to start when the system boots. The processes spawned by the init for each of these run levels are defined in the file “/etc/inittab
“.
Run Levels are numbered from zero to six and define the state of the machine after boot, as listed below.
Run Levels | Mode | Functions |
---|---|---|
0 | Halt | Halt the system. |
1 | Single-User Mode | Get the system into single user mode. |
2 | Multi-User Mode | Get the system into multiuser mode without networking. |
3 | Multi-User Mode with Networking | Get the system into multiuser mode with networking. |
4 | Undefined | Not used |
5 | X11 | Get the system into multiuser mode with networking and X windows. |
6 | Reboot | Reboot the system. |
The majority of Linux systems is based on runlevel 3 or 5. Although, users can modify these runlevels or create new ones based on their requirements.
The 0, 1, and 6 are reserved runlevels used for halting, getting into single user mode, and rebooting the system.
Init Command in Linux
In most Linux systems, the init command is used to send control commands to the init daemons that run as background processes.
$ init [OPTION]
The following is a list of all known options, along with their descriptions.
Commands | Description |
---|---|
0 | Shutdown the system. |
6 | Reboot the system. |
2, 3, 4, 5 | Start runlevelX.target unit. |
1, s, S | Enter rescue mode. |
q, Q | Reload the init daemon configuration. |
u, U | Re-execute the init daemon. |
Conclusion
There are numerous items that should be included, but the goal of this article is not to provide a detailed description of the init process or command; rather, it is to walk you through them.
If you are more interested in knowing the init process, then check this article, as this method of booting the system is deprecated with systemd, so there is no future plan to have a major update in this article.
If you are interested in learning about them from our site or want this article to be more concise, then do let me know in the comment section.
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.