systemctl cat: inspecting unit internals
In production diagnostics, the fastest way to see the effective unit file and understand top-level overrides is with systemctl cat. It streams the merged content of the base unit and all attached drop-ins to stdout, eliminating the need to manually hunt through /etc and /lib. For a Lead DevOps this is the starting point before any service change or boot-check.
Why systemctl cat matters
In typical infrastructures unit-files are shipped by packages, while local corrections live in drop-ins. systemctl cat shows the final config that systemd actually loads. Without this you might spend an hour hunting why a Service= changed but the service still starts with defaults. It’s also handy when auditing foreign code or prepping rollback scenarios: one command gives the full current state of a unit.
What the command shows
systemctl cat <unit> reads symbolic links, the base unit from /lib/systemd/system/ and any overrides from /etc/systemd/system/. The output is a concatenation ordered by priority: defaults are overridden by local settings. The command has no extensive flag set; it simply reflects what systemd has already read from the filesystem at query time. If output is long, pipe through grep or less since the utility does no truncation.
To view only the base unit without drop-in overlays, run systemctl show <unit> --property=FragmentPath to check active fragments, or inspect the file path via systemctl status <unit> --no-pager.
drop-in and override files
The drop-in mechanism uses .d directories. For a unit like nginx.service, overrides live in /etc/systemd/system/nginx.service.d/. Each .conf file there adds or overrides sections and keys. Files are loaded in lexicographic order: 00- first, 99- last. Priority is higher for files under /etc than /lib or /run. systemctl cat aggregates them in this order, making it easy to see which key came from where and how it overrides the default.
Directly editing files in /lib/systemd/system/ is not recommended — they get overwritten on package update. Always use drop-ins in /etc to preserve changes across reloads and updates.
Fragments and inheritance
Systemd supports fragments — drop-in pieces that can be conditioned on OS architecture or distro version. Fragments named starting with 00-, 10-, etc., define application order. Inheritance works through Unit, Service and Install sections. If a fragment defines After=, it appends to the existing value rather than replacing it fully, unless Replace= is specified in newer systemd versions. systemctl cat displays this inheritance whole, simplifying dependency chain auditing and hidden override hunting.
Practical examples of reading
The primary command looks like:
Output contains [Unit], [Service], [Install] sections with overlaid overrides. For services using multiple instances (e.g., docker.service), the command shows the accumulated config of all fragments.
Sometimes it helps to check which file is actually in use:
This returns the path to the active fragment, confirming systemctl cat assembled correctly.
If systemctl cat returns empty or “Unit not found”, verify the unit name via systemctl list-unit-files and check for the file in the expected directories.