In Unix-like operating systems, “run levels” refer to different states or modes that a system can be in. Each run level corresponds to a specific configuration of system services and resources, which determines which processes are running.
As seen in the previous topic Init Runlevels in Unix-like Systems, Runlevels define the state of the system and determine which services and processes are active.
Traditionally, Unix systems use run levels to manage system startup and shutdown. The specific run levels and their meanings can vary between different Unix-like systems, but they typically include the following common levels:
- Single-user mode (run level 1): Also known as maintenance mode, this run level is used for system maintenance tasks. In this mode, only a minimal set of services necessary for basic system operation are started, and the system boots to a single-user command line interface.
- Multi-user mode (run level 2): Historically, this was used as the default multi-user mode with networking. However, on many modern Unix-like systems, run level 2 is often the same as run level 3.
- Multi-user mode with networking (run level 3): This is typically the default mode for many Unix systems. It starts a full multi-user environment with networking capabilities.
- Multi-user mode with GUI (run level 4): Some Unix systems use this run level to start a multi-user environment with a graphical user interface (GUI). However, it is not always used, and run levels 2 and 3 may be configured to include GUI environments.
- System shutdown/reboot (run level 5): This run level is used to cleanly shut down or reboot the system.
- Reboot to firmware (run level 6): This run level is used to reboot the system, and it is typically set up to restart the computer hardware.
Additionally, there are special run levels, such as:
- 0 (halt): This run level is used to power off the system.
- S or s (single-user mode): Similar to run level 1, this is used for maintenance tasks but may have slight differences in behavior.
How to Use it
- To check the current run level, simply type
runlevel
and press Enter. - To change the run level, you’ll use a command like
sudo telinit <runlevel>
. For example, to switch to single-user mode (maintenance mode), you would typesudo telinit 1
and press Enter. - To reboot the system, use the command
sudo reboot
. - To power off the system, use the command
sudo poweroff
.
Remember to exercise caution when using these commands, especially when changing run levels, as it can affect the operation of your system. Always ensure you have saved any important work before making any major system changes.