runlevel
A runlevel is an operating state on a Unix and Unix-based operating system that is preset on the Linux-based system. Runlevels are numbered from zero to six.
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, or use the runlevel command to find out the machine's current runlevel to assess a system. For example, the runlevel can indicate whether or not the system's network is operational. Use the runlevel command /sbin/runlevel to find the current and previous runlevel of an operating system.
Runlevels zero through six 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 distros and Unix versions.
Each basic level has a different purpose. Runlevels 0, 1, 6 are always the same. Runlevels 2 to 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.
Runlevel 0 |
shuts down the system |
Runlevel 1 |
single-user mode |
Runlevel 2 |
multi-user mode without networking |
Runlevel 3 |
multi-user mode with networking |
Runlevel 4 |
user-definable |
Runlevel 5 |
multi-user mode with networking |
Runlevel 6 |
reboots the system to restart it |
Users can modify the preset runlevels or even create new ones if needed. Runlevel 4 is typically for user-defined runlevels.
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 allow the user to log in due to a corrupted /etc/passwd file or if you forget your password, you can solve these problems by booting into single-user mode.
There is a newer version of runlevels that consist of systemd targets, which is a method of starting up Linux-based systems.