// learn Β· linux Β· rhcsa Β· 10 min

systemd targets & dependencies.

A unit. A dependency. A target. How those three concepts let systemd start a hundred services in the right order, in parallel where it can. Pace through the model and the boot graph. Maps to RH134 service-management objectives.

systemd targets and dependencies explained with animations. Units, Requires vs Wants vs After vs Before, target nesting, the boot graph, systemctl isolate, and default.target. Covers the RHCSA EX200 exam objectives on systemd service management.
// systemd targets & dependencies

systemd is a graph engine. Every service is a node; every dependency is an edge. Targets are special nodes that bundle other nodes under a name. Booting is just "activate default.target and chase the edges".

// before you start
you should know
  • Β·Starting/stopping a service with systemctl
  • Β·Reading basic Linux logs (journalctl)
  • Β·What 'a process' is (PID, foreground/background)
by the end you'll

Read a unit file, distinguish the four dependency directives, and use systemctl isolate to switch system state without rebooting.

pace: 10 minutes

systemd β€” step 1 / 5 Β· unit file
/usr/lib/systemd/system/nginx.service[Unit]Description=High-performance HTTP serverAfter=network.target← ordering: start AFTER network is upWants=network-online.target← soft dep: nice to have[Service]Type=forkingExecStart=/usr/sbin/nginx← the command to runExecReload=/bin/kill -HUP $MAINPIDRestart=on-failure← auto-restart on crash[Install]WantedBy=multi-user.target← what 'enable' attaches it to

A unit file β€” the building block

Everything systemd manages is called a 'unit'. The most common type is a service β€” like nginx or sshd β€” but there are also timers (scheduled tasks), sockets, mounts, and the 'target' units you'll meet in step 3. Every unit is described by a small text file in INI format with up to three sections: [Unit] for metadata + what it depends on, [Service] for how to run it, [Install] for what 'enabling' attaches it to.

// commands
$systemctl cat nginx.service
$systemctl status nginx.service
$systemctl show nginx.service
// key insight

A target isn't something that runs β€” it's a label for a state. The state is "all these units are active". That's why isolate works the way it does: it says "make this state the truth" and systemd brings up what's needed, stops what isn't.

// exam-ready Β· systemctl toolkit
$systemctl status UNIT
$systemctl start / stop / restart UNIT
$systemctl enable / disable UNIT
$systemctl enable --now UNIT
$systemctl mask UNIT
$systemctl daemon-reload
$systemctl cat UNIT
$systemctl edit UNIT
$systemctl list-units --type=service
$systemctl list-units --failed
$systemctl list-dependencies UNIT
$systemctl get-default / set-default TARGET
$systemctl isolate TARGET
$journalctl -u UNIT
$journalctl -u UNIT -f
$systemd-analyze blame
// check yourself
4 quick questions
Q1

service-a depends on service-b. If service-b fails to start, service-a should NOT start. Which directive do you use?

Q2

What's the difference between After= and Requires=?

Q3

You're on a GUI system. You want to drop to a text-only console without rebooting. Which command?

Q4

Your service is enabled but won't start at boot. Best first command?

These aren't graded β€” they're just for active recall, which is what actually makes the lesson stick.

Read this lesson as text5 chapters Β· quiz answers

  1. 01A unit file β€” the building block

    Everything systemd manages is called a 'unit'. The most common type is a service β€” like nginx or sshd β€” but there are also timers (scheduled tasks), sockets, mounts, and the 'target' units you'll meet in step 3. Every unit is described by a small text file in INI format with up to three sections: [Unit] for metadata + what it depends on, [Service] for how to run it, [Install] for what 'enabling' attaches it to.

    • $ systemctl cat nginx.service β€” show the unit file
    • $ systemctl status nginx.service β€” live state + last log lines
    • $ systemctl show nginx.service β€” all resolved properties (deep dive)
  2. 02Dependencies β€” order and strength

    After= and Before= set ORDERING (when, relative to others). Requires= and Wants= set STRENGTH (must this dependency be running? what if it fails?). Requires is hard β€” failure cascades. Wants is soft β€” failure is logged but ignored.

    • $ systemctl list-dependencies nginx.service β€” see what nginx pulls in
    • $ systemctl list-dependencies --reverse nginx.service β€” see who needs nginx
  3. 03A target groups many units

    A target is a unit with no payload of its own β€” it exists to be a sync point. multi-user.target says 'when I'm reached, these services must be running'. That's how systemd bundles 50 services behind one named state.

    • $ systemctl list-units --type=target β€” all active targets
    • $ systemctl list-dependencies multi-user.target β€” what's in this target
  4. 04Targets nest β€” graphical β†’ multi-user β†’ basic β†’ sysinit

    Each target above 'requires' the one below it, so they stack like Russian dolls. From the bottom up: sysinit.target sets up mounts and cgroups; basic.target adds sockets, paths, and timers; multi-user.target adds the network, SSH, and your services; graphical.target adds the desktop (GDM). Reaching graphical.target pulls in everything below it automatically.

    • $ systemctl get-default β€” show current default target
    • $ systemctl set-default multi-user.target β€” boot to text login next time (no GUI)
    • $ ls -l /etc/systemd/system/default.target β€” default.target is just a symlink
  5. 05isolate β€” switch state without reboot

    systemctl isolate <target> activates that target AND stops every active unit that's NOT a dependency of it. So 'isolate multi-user.target' tears down the GUI but keeps SSH, networking, services. Same boot graph, different anchor.

    • $ systemctl isolate multi-user.target β€” drop GUI without rebooting
    • $ systemctl isolate rescue.target β€” drop to single-user with mounted FS
    • $ systemctl isolate emergency.target β€” bare minimum, root shell only
    • $ systemctl isolate graphical.target β€” back to GUI

Quiz β€” answers

service-a depends on service-b. If service-b fails to start, service-a should NOT start. Which directive do you use?
β†’Requires=service-b.serviceRequires is the hard dependency β€” if it fails, the dependent unit fails too. Wants is the soft version (logs but ignores).
What's the difference between After= and Requires=?
β†’After= sets ordering only; Requires= sets dependency strength (failure cascades)Two different axes β€” order (After/Before) vs strength (Wants/Requires). You almost always want both.
You're on a GUI system. You want to drop to a text-only console without rebooting. Which command?
β†’systemctl isolate multi-user.targetisolate activates the named target AND stops anything not in it. So GUI services stop; SSH/networking/your services keep running.
Your service is enabled but won't start at boot. Best first command?
β†’systemctl status YOURSVCstatus shows the current state plus the last few log lines β€” almost always tells you exactly what went wrong.
// more in linux

keep going β€” these pair well with what you just learned.

see all linux β†’

See also

back to RHCSA trackall lessons