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:
- single-user mode
- multi-user mode without network services started
- multi-user mode with network services started
- system shutdown
- system reboot
The exact setup of these configurations will vary from OS to OS, and from one Linux distribution to another. For 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. It is best to consult the particular 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.
Debian, as well as most of the distributions based on it, does not make any distinction between runlevels 2 to 5.
|S||Only run on boot (replaces /etc/rc.boot)|
|2–5||Full Multi-user with console logins and display manager if installed|
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.
|2||Graphical multi-user with networking|
|3-5||Unused but configured the same as runlevel 2|
Specific to Ubuntu OS
To see the current (and previous) runlevel:
To switch runlevels:
sudo init $runlevel
For example, to reboot:
sudo init 6
To change the default runlevel, use your favorite text editor on /etc/init/rc-sysinit.conf…
sudo vim /etc/init/rc-sysinit.conf
Change this line to whichever runlevel you want…
Then, at each boot, upstart will use that runlevel.