Older Linux systems used runlevels (0–6) to define system states, such as single-user, multi-user with networking, graphical, shutdown and reboot. systemd replaced them with targets: named groups of units that the system brings up. The concepts map closely, and the old commands still work, but knowing targets helps when you set the default boot mode, enter rescue mode or write service files.
Runlevels and their target equivalents
| Runlevel | systemd target | Meaning |
|---|---|---|
| 0 | poweroff.target |
Shut down |
| 1 / S | rescue.target |
Single-user, maintenance |
| 2, 3, 4 | multi-user.target |
Normal server mode: multi-user, networking, no GUI |
| 5 | graphical.target |
Multi-user plus a graphical login |
| 6 | reboot.target |
Reboot |
| — | emergency.target |
Minimal shell, root mounted read-only |
runlevel3.target and friends exist as aliases for compatibility.
What’s the current and default target?
systemctl get-default # target used at boot
systemctl list-units --type=target --state=active
runlevel # legacy view: e.g. "N 3"
who -r
Servers should default to multi-user.target. If a minimal server image somehow has graphical.target with no desktop installed, it still boots, because systemd just pulls in what exists.
Change the default target
sudo systemctl set-default multi-user.target
sudo systemctl set-default graphical.target # if a desktop is installed
This updates the /etc/systemd/system/default.target symlink. If you installed a desktop environment on a VPS for remote access and want to save resources, switch back to multi-user.target and start the GUI only when needed.
Switch target now
sudo systemctl isolate multi-user.target # stop the GUI, keep the server running
sudo systemctl isolate rescue.target # drop to single-user (stops most services, including sshd)
Careful: isolating rescue.target or emergency.target over SSH cuts your connection, because networking and sshd stop. Do it from the VNC console.
Shortcuts:
sudo systemctl rescue
sudo systemctl emergency
sudo systemctl default # back to the default target
sudo systemctl poweroff # = shutdown -h now
sudo systemctl reboot
Boot into a target once (from GRUB)
At the GRUB menu, press e and add one of these to the linux line:
systemd.unit=rescue.target
systemd.unit=emergency.target
systemd.unit=multi-user.target
The old runlevel numbers work too: append 1 or 3. See Linux rescue mode and GRUB.
Rescue vs emergency
| rescue.target | emergency.target | |
|---|---|---|
| Root filesystem | Read-write | Read-only |
| Other filesystems (fstab) | Mounted | Not mounted |
| Services | Basic system services only | Almost none |
| Networking | No | No |
| Use when | Maintenance, fixing services, resetting configs | fstab or filesystem problems, rescue mode itself fails |
Both require the root password. Without one, use init=/bin/bash.
How services attach to targets
In a service unit:
[Install]
WantedBy=multi-user.target
systemctl enable myapp creates a symlink in /etc/systemd/system/multi-user.target.wants/, so the service starts whenever multi-user.target is reached, which means every normal boot.
See what a target pulls in:
systemctl list-dependencies multi-user.target
systemctl list-dependencies --reverse nginx.service # which targets want nginx
Useful special targets for unit files
| Target | Use in your units |
|---|---|
network-online.target |
After= + Wants= it if your service needs the network fully up (e.g. it connects to a remote DB at start) |
network.target |
Only means networking has started. Enough for servers that listen on ports |
time-sync.target |
Order after time synchronisation |
local-fs.target / remote-fs.target |
After local or network filesystems are mounted |
timers.target |
Where .timer units are enabled |
See systemd unit files.
Quick reference
| Task | Command |
|---|---|
| Default target | systemctl get-default |
| Set default | systemctl set-default multi-user.target |
| Switch now | systemctl isolate multi-user.target |
| Rescue / emergency | systemctl rescue / systemctl emergency |
| One-off at boot | systemd.unit=rescue.target in GRUB |
| Target contents | systemctl list-dependencies multi-user.target |
Related: the Linux boot process and systemctl.