What is runlevel?
Runlevels determine which programs can execute after the OS boots up. The runlevel defines the state of the machine after boot.
Systems administrators set the default runlevel of a system according to their needs. Administrators also use the runlevel command to find out the machine’s current runlevel to assess a system. For example, the runlevel can indicate whether the system’s network is operational. Use the runlevel command /sbin/runlevel to find the current and previous runlevel of an OS.
Runlevels 1 through 6 are generally delegated to single-user mode, multi-user mode with and without network services started, system shutdown and system reboot. The setup of these configurations differs between Linux distributions and Unix versions.
Each basic level has a different purpose. Runlevels 0, 1 and 6 are always the same. Runlevels 2, 3, 4 and 5 are different depending upon the Linux distribution in use. Only one runlevel is executed when the system is booted. They are not implemented sequentially. For example, either Runlevel 4 or 5 or 6 is executed, not 4 then 5 then 6.
Each runlevel has its own systemd-target. Runlevels relate to specific systemd-targets. Systemd-targets are methods of starting up Linux-based systems. They are written out commands which differ from a runlevel command that consists only of a number.
|Shuts down the system
|Multi-user mode without networking
|Multi-user mode with networking
|Multi-user mode with networking (supports GUI)
|Reboots the system to restart it
Users can modify the preset runlevels or even create new ones if needed.
Booting a system into different runlevels solves certain problems. For example, if a machine fails to boot due to a damaged configuration file, refuses to let the user log in due to a corrupted /etc/passwd file or if the user forgets their password, single-user mode can solve these problems.