Linux runlevels and systemd targets explained
Runlevels define what is running on a Unix system: single-user maintenance, a text-only server, or a full graphical desktop. Modern Linux replaced them with systemd targets, but the idea and many of the commands still work.
The classic runlevels
With System V init, the first process (init) ran the system in one runlevel at a time, numbered 0 to 6:
| Runlevel | Purpose (Red Hat style) | systemd target |
|---|---|---|
| 0 | Halt and power off | poweroff.target |
| 1, S | Single-user mode for maintenance; no network, root only | rescue.target |
| 2 | Multi-user without NFS (Debian used 2 as its normal full runlevel) | multi-user.target |
| 3 | Full multi-user, text console: the usual server state | multi-user.target |
| 4 | Unused, free for local definitions | multi-user.target |
| 5 | Multi-user with a graphical login screen | graphical.target |
| 6 | Reboot | reboot.target |
The default runlevel was set in /etc/inittab with a line such as id:3:initdefault:, and each runlevel had a directory, /etc/rc3.d and so on, full of links to start (S) and kill (K) scripts in /etc/init.d. If you maintain an old system you will still meet these files.
systemd targets
Every current major Linux distribution (Debian, Ubuntu, RHEL and its rebuilds, Fedora, SUSE, Arch) boots with systemd. Instead of numbered runlevels it has targets: named groups of services that should be running together. A target can depend on other targets, so graphical.target includes everything in multi-user.target plus the display manager.
Older systemd versions (up to 257, for example RHEL 10) kept aliases runlevel0.target to runlevel6.target and the old runlevel, init 3 and telinit commands for compatibility. systemd 258 removed them (Fedora 43, Ubuntu 26.04 and later), and Debian 13 keeps no runlevel records, so runlevel only prints unknown there. Use systemctl get-default and systemctl isolate instead.
See the current state
systemctl get-default # the target the system boots into
systemctl list-units --type=target # targets that are active now
runlevel # older Linux only: previous and current runlevel, e.g. "N 5"
who -r # current runlevel on AIX, Solaris, HP-UX and older Linux
Change the target now
sudo systemctl isolate multi-user.target # stop the graphical session, keep everything else
sudo systemctl isolate graphical.target # start the desktop again
sudo systemctl rescue # single-user rescue mode
sudo systemctl poweroff # runlevel 0
sudo systemctl reboot # runlevel 6
isolate starts the named target and stops everything not needed by it, just like switching runlevels with telinit 3 used to on older systems. On a remote server, be careful: rescue and emergency stop the network, so you lose your SSH session.
Set the default target
sudo systemctl set-default multi-user.target # boot to a text console (servers)
sudo systemctl set-default graphical.target # boot to the graphical login
This replaces editing initdefault in /etc/inittab. It creates the link /etc/systemd/system/default.target.
Choose a target for one boot
To boot into a different target once, for example to fix a broken desktop:
- At the GRUB menu, highlight the entry and press e.
- Find the line starting with
linuxand add one of these at the end:systemd.unit=multi-user.target(or just3): text modesystemd.unit=rescue.target(or1,single): single-user mode, asks for the root passwordsystemd.unit=emergency.target: an even more minimal shell, root file system read-only
- Press Ctrl+X or F10 to boot.
To reset a forgotten root password, rescue mode does not help, because it asks for that password. Add rd.break (RHEL, Fedora; see Red Hat's documentation on resetting the root password) or init=/bin/bash to the linux line instead, or boot a live USB.
If GRUB's menu does not appear, hold Shift (BIOS) or press Esc (UEFI) during boot. When the root account is locked, as on Ubuntu, rescue mode cannot ask for a password; boot from a live USB instead (see booting Linux from USB).
Which services start in a target
systemctl list-dependencies multi-user.target # tree of what the target pulls in
systemctl is-enabled nginx # will nginx start at boot?
sudo systemctl enable --now nginx # start now and at every boot
sudo systemctl disable --now cups # stop now and not at boot
"Enabling" a service links it into a target, usually multi-user.target, just as old init scripts were linked into /etc/rc3.d. See systemctl for everything else systemctl can do, and journalctl to read the boot log when something does not start.
Runlevels on other Unix systems
- Oracle Solaris 11
- Uses SMF milestones instead of runlevels:
svc:/milestone/single-user,multi-userandmulti-user-server.svcadm milestoneswitches between them, andwho -rshows the equivalent runlevel.init 0,init 5(power off) andinit 6still work. - IBM AIX
- Still uses
/etc/inittaband runlevels 0-9. The default is 2, which is full multi-user. Change withtelinit, edit entries withmkitabandchitab, and list them withlsitab -a. - FreeBSD, OpenBSD, NetBSD
- No numbered runlevels: the system boots either single-user (
boot -sat the loader) or multi-user, and services are switched on in/etc/rc.conf(FreeBSD, NetBSD) or in/etc/rc.conf.localwithrcctl(OpenBSD). - HP-UX
- System V runlevels with
/sbin/rc3.ddirectories and/etc/inittab. The default is 3 (full multi-user), which also starts the CDE graphical login on workstations.