Runlevels
The runlevel defines the state of the system after boot. Multiple runlevels can be customised to boot the same system into very different states (e.g. Graphical vs. textual console).
The contents of /etc/rc[0-6].d/ (e.g. /etc/rc2.d/) determines exactly what happens at that runlevel.
In Ubuntu (and Debian), there are seven runlevels:
- Runlevel 0: Shutdown
- This runlevel will leave the system shut down when executed.
- Runlevel 1: recovery mode
- A.k.a. "maintenance mode", "single-user mode". This is the simplest possible sequence that will make the system accessible.
- Runlevel 2: Normal / Default
- This is the standard which will boot the system into the graphical interface, e.g. Gnome.
- Runlevel 3-5: Same as runlevel 2
- By default, these are identical with runlevel 2, but they can be customised and used to boot the system into a different state.
- Runlevel 6: Reboot
- This runlevel will shutdown and reboot the system.
This description assumes the system is a standard Ubuntu Desktop installation.
Runlevels are low-level things to be messing with - better to check how they work in your exact system configuration.
The runlevel Command
This command prints the previous and current runlevels:
$ runlevel N 2
N (for "None") as previous means the runlevel is unchanged since booting.
It is possible to change runlevel using telinit [0-6], but the right way is to use the shutdown command or one of it's aliases.