Hands-on Lab·Linux Foundation Certified System Administrator
Writing a unit, and what ordering means
Writing a unit is a task you will be given, and the marks are in the parts that are not the ExecStart line: the environment your script gets, whether a failure is recorded, and the difference between needing another unit and running after it. This guide writes one, breaks one deliberately, and then modifies a unit without editing it.
Operations Deployment Guide 14 of 38 Intermediate
- PlatformsUbuntu 26.04 LTS + AlmaLinux 10.2
- LVM2.03.31 (Ubuntu) / 2.03.36 (AlmaLinux)
- nftables1.1.6 (Ubuntu) / 1.1.5 (AlmaLinux)
- TimeAbout 20 min
systemd 257 on RHEL 10; identical on the lab's Ubuntu 259 hosts. systemd-analyze verify and drop-in directories have been stable for years.
- Firewallufw 0.36.2 enabled but reporting inactive / firewalld active
- Network confignetplan + systemd-networkd / NetworkManager 1.56.0
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| LFCS-A01 | 192.168.0.70 | Ubuntu 26.04 LTS | Primary host - most guides run only here | 2 Core | 4 GB | 50 GB |
| LFCS-C01 | 192.168.0.72 | AlmaLinux 10.2 | The other distribution - dnf, firewalld and NetworkManager | 2 Core | 4 GB | 50 GB |
This guide includes
Use this because writing a unit is a task you will be given. This matters because Requires is not After - a unit can require another and still start before it.
- writing a script and a unit that runs it, then reading what the unit gave it
- running
daemon-reload, and seeing what systemd remembers about a failure - separating
RequiresfromAfter - changing a shipped unit with a drop-in rather than editing it
- writing the same unit on Ubuntu, and verifying it there
Before you start
-
A script, and a unit that runs it
-
daemon-reload, and then what the unit gave the script
-
A unit that fails, and what systemd remembers
-
Requires is not After
-
A drop-in, instead of editing the unit
-
The same unit file on Ubuntu