Systemd units and dependencies
Quick answer
A unit is a systemd-managed resource. Service, socket, timer, mount and target units express different jobs, and dependencies describe how they relate.
Prepare the practice environment
Run python3 lab-fixtures/boot-services/setup.py from the extracted package root as an ordinary user in a disposable Linux environment. Enter the printed path and check pwd. Use a fresh fixture and a fresh Bash process for each offline example, with LC_ALL=C and set -o pipefail. Do not omit the explicit offline root. Read the fixture README before VM-only examples; never run those on the host. Static checks do not start a service.
How it works
The unit suffix indicates type. [Unit] contains shared metadata and dependencies, [Service] describes execution, and [Install] describes enablement links. Wants= pulls a unit into a start transaction without making its success mandatory; Requires= creates a stronger requirement, with failure behavior also influenced by ordering. After= orders units if both are scheduled; it does not start the named unit by itself. A target groups units and is not a daemon. A timer can activate another unit on a schedule. Distinguish readiness from start ordering; After= alone does not guarantee a network endpoint is reachable.
Imagine the report needs a preparation task. Wants= plus After= requests preparation and orders report startup after its start job completes, but a failed preparation can still leave the report eligible to start. For a required successful oneshot preparation, consider Requires= together with After=; still verify the actual input or application readiness separately. Offline verification checks definitions, not this runtime outcome.
Try the examples
The report requests preparation and orders itself after it.
Expected stdout:
Wants=bm-prep.serviceAfter=bm-prep.serviceThe timer is illustrative; it will not be enabled or started.
Expected stdout:
OnBootSec=5minUnit=bm-report.servicesystemd-analyze verify ./bm-prep.service ./bm-report.service ./bm-report.timer && printf 'verification passed\n'Verification reads files and checks dependencies and executable availability; no unit is launched.
Expected stdout:
verification passedCommon mistakes
Do not replace Wants= with Requires= indiscriminately or mistake After= for a readiness probe. Avoid dependency cycles.
Practice
Explain what happens if only After= is present and the preparation unit is not requested elsewhere. Inspect the timer and identify the unit it would activate.
Related references
Study: systemctl. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Systemd units and dependencies — Knowledge Check
Apply boot and systemd concepts to offline unit files and VM-only scenarios.
What does After= do by itself?
Which directive pulls in a weak dependency?
What is a target?
What does offline verify demonstrate?