When systemd boots, it has a goal: reach a particular state, such as a multi-user server or a graphical desktop. Those goals are called targets. A target is a unit that mainly groups other units.
Targets
Common targets are:
multi-user.targeta full system with text logingraphical.targetmulti-user plus a graphical loginrescue.targeta minimal single user repair modeemergency.targetan even smaller shell, for serious troublepoweroff.targetandreboot.target
They roughly replace SysV runlevels: 1 maps to rescue, 3 to multi-user, 5 to graphical, 0 to poweroff and 6 to reboot.
The default target
$ systemctl get-default
graphical.target
$ sudo systemctl set-default multi-user.targetThe change takes effect at the next boot. To switch a running system now, use isolate:
$ sudo systemctl isolate multi-user.targetisolate stops units that the new target does not need, so a graphical session can end without warning.
Dependencies and ordering
To reach a goal, systemd follows dependencies between units:
Wants=pulls in another unit, but carries on if it fails.Requires=is a stronger requirement. If the required unit is explicitly stopped, this one is stopped too.After=andBefore=set order only. They do not pull anything in.
So a service that needs a database often has both Requires= and After=. Units with no ordering between them can start in parallel.
When you enable a unit that says WantedBy=multi-user.target, systemd creates a link in multi-user.target.wants. That is how the unit joins the goal.
Exploring
$ systemctl list-dependencies multi-user.targetThis draws a tree of what the target pulls in. To see where boot time went:
$ systemd-analyze
$ systemd-analyze blameblame lists units by how long they took to start. A slow unit does not necessarily delay the whole boot, because others run in parallel. systemd-analyze critical-chain helps show what was actually waiting.
Try it
Check your default target and list its dependencies. Run systemd-analyze blame and look at the top three entries. Do not change the default or isolate a target on a machine that other people are using.
Check your understanding
Systemd Goals
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.