Skip to content

Systemd

← Back to all decks

11 cards — 🟢 3 easy | 🟡 5 medium | 🔴 3 hard

🟢 Easy (3)

1. Where do admin-override unit files live, and why do they take precedence over vendor unit files?

Show answer Admin overrides live in /etc/systemd/system/. Vendor unit files live in /usr/lib/systemd/system/. Admin overrides win because /etc/systemd/system/ has higher priority in the systemd unit file search path.

2. What systemd target replaces traditional runlevel 3, and what does it provide?

Show answer multi-user.target replaces runlevel 3. It provides a non-graphical multi-user system with networking and all standard services running.

3. How do you view only the logs for a specific systemd service using journalctl?

Show answer Use journalctl -u . For example, journalctl -u nginx.service shows only nginx logs. Add --since or --follow for time filtering or live tailing.

🟡 Medium (5)

1. What is the difference between Wants= and Requires= in a systemd unit file?

Show answer Wants= is a soft dependency: if the wanted unit fails to start, the depending unit still starts. Requires= is a hard dependency: if the required unit fails, the depending unit also fails to start. Wants= is preferred for most cases to avoid cascading failures.

2. How do you safely customize a vendor-provided systemd unit file without editing it directly?

Show answer Use systemctl edit to create a drop-in override file at /etc/systemd/system/.d/override.conf. Use systemctl edit --full to create a full replacement copy. After any manual edit, run systemctl daemon-reload.

3. What command enables a service to start at boot AND starts it immediately in one step?

Show answer systemctl enable --now . The --now flag combines enable (creates symlinks for boot) and start (activates the service immediately) into a single command.

4. How does systemd enforce resource limits on services?

Show answer systemd uses cgroups (control groups). Every service runs in its own cgroup slice, which allows systemd to enforce CPU, memory, and I/O limits using directives like CPUQuota=, MemoryMax=, and IOWeight= in the unit file's [Service] section.

5. What command would you use to debug slow boot times and identify which units are taking the longest?

Show answer systemd-analyze blame lists units by startup time. systemd-analyze critical-chain shows the critical path of the boot sequence. systemd-analyze plot > boot.svg generates a visual SVG timeline of the entire boot.

🔴 Hard (3)

1. Describe the simplified boot sequence from firmware to running services in a systemd-based system.

Show answer firmware -> bootloader -> kernel -> initramfs -> systemd (PID 1) -> default.target (usually multi-user.target or graphical.target) -> dependency tree of units. systemd as PID 1 manages the entire service dependency tree from that point.

2. What is the difference between After=/Before= and Wants=/Requires= in systemd unit files?

Show answer After= and Before= control ordering only: they determine the sequence in which units start but do not create a dependency. Wants= and Requires= create actual dependencies (pull in units) but do not control order. To both require a unit and ensure it starts first, you need both Requires= and After= together.

3. Why must you run systemctl daemon-reload after manually editing a unit file, and what happens if you forget?

Show answer daemon-reload tells systemd to re-read all unit files from disk. If you forget, systemd continues using the cached in-memory version of the unit file, so your changes have no effect. systemd will log a warning that unit files have changed on disk and suggest running daemon-reload.