A runlevel is the operating state of a Linux operating system. Linux relies on runlevels to determine which services are started and which services are stopped. Runlevels are numbered from 0 to 6, with each runlevel offering different services. Runlevels 0, 1, and 6 are standard runlevels reserved for special purposes. Runlevels 2, 3, and 4 are used for whatever purpose you or your Linux distribution provider decide.
The /etc/inittab file defines the runlevels on a Linux system. Here is an example /etc/inittab file:
Here is a brief description of the runlevels in Linux:
0 – shuts down the system.
1, s, or S – single-user mode. Limited number of services are started. Usually used for system maintenance.
2 – text mode with multiple users, but without network support.
3 – text mode with multiple users and networking
4 – usually not defined
5 – the default runlevel. Multiuser GUI. The most common runlevel for Linux workstations.
6 – reboots the system. Used to restart a machine in the default runlevel.
To display your current runlevel, use the runlevel command:
The first character displayed is the system’s previous runlevel (3). When this character is N, this means the system hasn’t switched runlevels since booting. The second number is the current runlevel (5).
You can also call a runlevel directly using the init daemon itself. For example, if you would like to perform some maintenance tasks on your Linux installation, you can switch to runlevel 1 by using the init 1 command.