What are systemd targets, and how do they relate to old runlevels?
A target is a group of units that represents a system state, such as multi-user.target (text mode, networking) or graphical.target (with a desktop). They replace SysV runlevels: runlevel 3 is multi-user.target and 5 is graphical.target. Check or change with systemctl get-default and set-default.
Explain it simply
Old Linux had numbered runlevels from 0 to 6. systemd uses named targets instead. Think of them as modes of a phone: normal, airplane, safe mode.
Mapping:
- runlevel 0 →
poweroff.target - runlevel 1 →
rescue.target(single user, minimal) - runlevel 3 →
multi-user.target(text login, network, services) - runlevel 5 →
graphical.target(multi-user plus display manager) - runlevel 6 →
reboot.target
A target pulls in the units it needs: graphical.target requires multi-user.target.
Commands: systemctl get-default shows the boot target. sudo systemctl set-default multi-user.target makes servers boot without a GUI. sudo systemctl isolate rescue.target switches now. systemctl list-units --type=target lists active ones.
When you write a service, WantedBy=multi-user.target means "start this in normal server mode".
Example
systemctl get-default
# graphical.target
sudo systemctl set-default multi-user.target
systemctl list-units --type=target | head -3What to say in the interview
"A target groups units into a system state. multi-user.target is the old runlevel 3 and graphical.target is runlevel 5. I set a server default with set-default multi-user.target, and WantedBy in a unit decides which target starts it."
Common mistakes
- Editing /etc/inittab, which does not exist on systemd systems.