Part II · Your system
20.4 systemd targets
alsotargettargetsrunleveldefault targetmulti-user.targetgraphical.targetrescue modeemergency mode
TL;DR
- A target is a stage the system can reach.
multi-user.target: text mode with network and services.graphical.target: the same plus a login screen. - Boot stops at the default target:
systemctl get-defaultshows it,set-defaultchanges it. rescue.targetandemergency.targetare minimal modes for repairs.
systemctl get-default
sudo systemctl set-default multi-user.target
sudo systemctl isolate rescue.target # switch now
On your machine
$ atfq 20.4 Firmware UEFI · Secure Boot on Kernel 6.12.48-amd64 Cmdline BOOT_IMAGE=/vmlinuz-6.12.48-amd64 root=UUID=3f1c2a9e-8b7d-4e21-9c55-0a6b2d7e9f10 ro rootflags=subvol=@ quiet splash Init systemd · default target graphical.target Loader systemd-boot 256.4 · 1 unified kernel image(s) Up 3 days, 4 h
An example: Alice's laptop, one of the test machines. In your terminal, this block shows your own machine, read live.
Pitfalls
isolatestops every unit the new target doesn't need: from a desktop, going tomulti-user.targetcloses your session.- For a single boot, add
systemd.unit=rescue.targetto the kernel command line from the boot menu (see 20.2). - Rescue and emergency modes ask for the root password. Where root is locked (Ubuntu), they can't open a shell.
Deep dive 2 questions
How do targets replace runlevels?
SysV init had numbered runlevels, 0 to 6, with fixed meanings. Targets
have names, depend on each other and can be combined. Aliases such as
runlevel3.target (multi-user) and runlevel5.target (graphical) keep old
habits working.
Rescue or emergency?
rescue.target mounts the filesystems, starts a few basic services and
opens a root shell. emergency.target mounts only the root filesystem,
read-only, for when even /etc/fstab is broken.