Unlike most non-UNIX operating systems which only have 2 modes of functionality (on and off), UNIX operating systems, including Linux, have different runlevels such as "maintenance" runlevel or "multi-user" runlevel, etc.
Runlevels are numbered from 0 to 6 and will vary from one Linux
distribution to another. The description for each runlevel functionality is
sometimes documented in /etc/inittab.
Table 2.1. Linux runlevels
| Runlevel | Purpose |
|---|---|
| 0 | Shuts down the machine safely. The operating system will also attempt to poweroff the system if possible |
| 1 | Single user mode. Only one terminal is available
for the (single) user root.
All other users are logged out |
| 2[a] | Multi-user mode, but does not start NFS. Network services like email or web services are also stopped |
| 3[a] | Full multi-user mode. Selected network services are all on. |
| 4[a] | Not defined and generally unused |
| 5[a] | Like runlevel 3 but runs a Display Manager as well |
| 6 | restarts the machine safely |
[a] These runlevels may vary in functionality between Linux flavours. But these descriptions correspond to the current LSB specification. | |
Both init and telinit are used to switch from one runlevel to another. Remember that init is the first program launched after the kernel has accessed the root device.
At boot time init is instructed which runlevel to reach in
/etc/inittab with the line:
id:5:initdefault:
When the system is started it is possible to change runlevels by invoking init (or telinit which is a symbolic link pointing at init).
For example we switch to runlevel 4 with either of the next commands:
init 4 telinit 4
The PID for init is always 1. It is possible to find out which runlevel the system is currently in with the command runlevel
runlevel N 5
The first number is the previous runlevel (or N if not applicable) and the second number is the current runlevel.