Pcornel
Linux · systemd & Services

Units

Cheat sheet · https://pcornel.dk/topic.php?topic=2718

Back to the Topic

Answer

A systemd unit is anything systemd manages, named by type suffix: .service (daemon), .socket, .timer, .mount, .target (group), .path, .device and more. Units have state (active, inactive, failed) and can depend on each other.

Remember

Unit files live in /usr/lib/systemd/system (packages), /etc/systemd/system (admin, wins) and /run. Override with drop-ins (systemctl edit <unit>) instead of editing package files.

First checks

  • systemctl status <unit> — state, main PID, recent log lines
  • systemctl list-units --failed — failed units
  • journalctl -u <unit> -b — the unit's log since boot
  • systemctl cat <unit> — unit file plus drop-ins
  • systemd-analyze verify <unit> — unit file errors

Verify in this order

unit file loaded → dependencies resolved → unit started → active (or failed) → logged in the journal

Where it usually breaks

First mismatch in persistent unit/config/generator → dependency/order graph → systemd state → process/cgroup → socket/resource dependency → journal → consumer check; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2718

Confirmation

Confirm action

Continue?