The term runlevel refers to a mode of operation in one of the computer operating systems that implement Unix System V-style initialization. Conventionally, seven runlevels exist, numbered from zero to six; though up to ten, from zero to nine, may be used. S is sometimes used as a synonym for one of the levels. Only one "runlevel" is executed on bootup - run levels are not executed sequentially, i.e. either runlevel 2 OR 3 OR 4 is executed, not 2 then 3 then 4.
"Runlevel" defines the state of the machine after boot. Different runlevels are typically assigned to:
The exact setup of these configurations will vary from OS to OS, and from one Linux distribution to another. Example, runlevel 4 might be multi-user, GUI, no-server on one distribution, and nothing on another. Note the difference in the Red Hat and Slackware distributions charted in this article. However, "runlevels" do commonly follow patterns described in this article. When installing Linux, it is best to consult that distribution's available user guides.
In standard practice, when a computer enters runlevel zero, it halts, and when it enters runlevel six, it reboots. The intermediate runlevels (1-5) differ in terms of which drives are mounted, and which network services are started. Default runlevels are typically 3, 4, or 5. Lower run levels are useful for maintenance or emergency repairs, since they usually don't offer any network services at all. The particular details of runlevel configuration differ widely among operating systems, and also among system administrators.
The runlevel system replaced the traditional /etc/rc script used in Version 7 Unix.
Contents |
ID | Name | Description |
---|---|---|
0 | Halt | Shuts down the system. |
S | Single-User Mode | Does not configure network interfaces or start daemons.[2] |
6 | Reboot | Reboots the system. |
^ = Almost all systems use runlevel 1 for this purpose. This mode is intended to provide a safe environment to perform system maintenance. Originally this runlevel provided a single terminal (console) interface running a root login shell. The increasing trend towards physical access to the computer during the boot process has led to changes in this area.
The Linux operating system can make use of runlevels through the programs of the sysvinit project. After the Linux kernel has booted, the init program reads the /etc/inittab file to determine the behavior for each runlevel. Unless the user specifies another value as a kernel boot parameter, the system will attempt to enter (start) the default runlevel.
Major Linux distributions agreed to define the following runlevels as part of the Linux Standard Base specification[1]:
ID | Name | Description |
---|---|---|
0 | Halt | Shuts down the system. |
1 | Single-User Mode | Mode for administrative tasks.[2][3] |
2 | Multi-User Mode | Does not configure network interfaces and does not export networks services.[4] |
3 | Multi-User Mode with Networking | Starts the system normally.[5] |
4 | Not used/User-definable | For special purposes. |
5 | Start the system normally with appropriate display manager. ( with GUI ) | As runlevel 3 + display manager. |
6 | Reboot | Reboots the system. |
^ = The additional behavior of this runlevel varies greatly. All distributions provide at least one virtual terminal. Some distributions start a login shell as the superuser; some require correctly entering the superuser's password first; others provide a login prompt, allowing any user access.
^ = In some cases, runlevels 2 and 3 function identically; offering a Multi-User Mode with Networking.
Debian, as well as most of the distributions based on it, like early Ubuntu, does not make any distinction between runlevels 2 to 5.
ID | Description |
---|---|
0 | Halt |
1 | Single-User mode |
2-5 | Full Multi-User with console logins and display manager if installed |
6 | Reboot |
Ubuntu 6.10 (Edgy Eft) and later contain Upstart as a replacement for the traditional init-process, but they still use the traditional init scripts and Upstart's SysV-rc compatibility tools to start most services and emulate runlevels.
Red Hat as well as most of its derivatives (such as CentOS) uses runlevels like this [3] :
ID | Description |
---|---|
0 | Halt |
1 | Single-User mode |
2 | Multi-user mode console logins only (without networking) |
3 | Multi-User mode, console logins only |
4 | Not used/User-definable |
5 | Multi-User mode, with display manager as well as console logins (X11) |
6 | Reboot |
Which services are started in which runlevels can be managed with the chkconfig tool, which keeps its configuration settings under /etc/rc.d/. /sbin/chkconfig --list lists all the services controlled by chkconfig and whether they are on/off for each runlevel. Setting a service A controlled by chkconfig, for levels X, Y and Z is as simple as /sbin/chkconfig --level XYZ A on
SUSE uses a similar setup to Red Hat:
ID | Description |
---|---|
0 | Halt |
1 or S | Single-User mode |
2 | Multi-User mode without networking |
3 | Multi-User mode, console logins only |
4 | Not used/User-definable |
5 | Multi-User mode with display manager |
6 | Reboot |
The services that run under a specific runlevel can be modified with YaST | System Services (runlevel) or with chkconfig command like the Red Hat based distributions.
Slackware Linux uses runlevel 1 for maintenance, as on other Linux distributions; runlevels 2, 3 and 5 identically configured for a console (with all services active); and runlevel 4 adds the X Window System.
ID | Description |
---|---|
0 | Halt |
1 | Single-User mode |
2 | Unused but configured the same as runlevel 3 |
3 | Multi-User mode without display manager |
4 | Multi-User mode with display manager |
5 | Unused but configured the same as runlevel 3 |
6 | Reboot |
ID | Description |
---|---|
0 | Halt |
1 | Single-User (Maintenance Mode) |
2 | Not used |
3 | Multi-User |
4 | Not used |
5 | Multi-User with X11 |
6 | Reboot |
ID | Description |
---|---|
0 | Halt |
1 or S | Single-User mode |
2 | Multi-User mode without networking |
3 | Multi-User mode |
4 | Aliased for runlevel 3 |
5 | Aliased for runlevel 3 |
6 | Reboot |
ID | Description |
---|---|
0 | Shut down system, power-off if hardware supports it (only available from the console) |
1 | Single-User mode, all filesystems unmounted but root, all processes except console processes killed |
2 | Multi-User mode |
3 | Multi-User mode with RFS (and NFS in Release 4) filesystems exported |
4 | Multi-User, User-definable |
5 | Halt the operating system, go to firmware |
6 | Reboot |
s, S | Identical to 1, except current terminal acts as the system console |
ID | Description |
---|---|
0 | Operating system halted; (SPARC only) drop to OpenBoot prompt |
S | Single-User mode with only root filesystem mounted (as read-only) |
1 | Single-User mode with all local filesystems mounted (read-write) |
2 | Multi-User mode with most daemons started |
3 | Multi-User mode; identical to 2 (runlevel 3 runs both /sbin/rc2 and /sbin/rc3), with filesystems exported, plus some other network services started. |
4 | Alternative Multi-User mode, User-definable |
5 | Shut down, power-off if hardware supports it |
6 | Reboot |
ID | Description |
---|---|
0 | System halted |
S | Single-User mode, booted to system console only, with only root filesystem mounted (as read-only) |
s | Single-User mode, identical to S except the current terminal acts as the system console |
1 | Single-User mode with local filesystems mounted (read-write) |
2 | Multi-User mode with most daemons started and Common Desktop Environment launched |
3 | Identical to runlevel 2 with NFS exported |
4 | Multi-User mode with VUE started instead of CDE |
5, 6 | Not used/User-definable |
The BSD variants don't use the concept of run levels, although on some versions init(8) provides an emulation of some of the common run levels.
AIX does not follow the System V R4 (SVR4) run level specification, with run levels from 0 to 9 available, as well as from a to c. 0 and 1 are reserved, 2 is the default normal multi-user mode and run levels from 3 to 9 are free to be defined by the administrator. Run levels from a to c allow the execution of processes in that run level without killing processes started in another.
ID | Name | Description |
---|---|---|
0 | reserved | |
1 | reserved | |
2 | Normal Multi-User mode | default mode |