LinuxCommandLibrary

systemctl-cat

View final systemd unit definition

TLDR

Show the contents and absolute path of a unit file

$ systemctl cat [unit]
copy

Show the contents of multiple unit files
$ systemctl cat [unit1 unit2 ...]
copy

Show the contents of a unit file for a template
$ systemctl cat [template@]
copy

SYNOPSIS

systemctl cat [OPTIONS...] UNIT...

PARAMETERS

UNIT...
    Specifies the name(s) of the systemd unit(s) whose effective configuration content should be displayed. Examples include `myservice.service` or `multi-user.target`.

--user
    When specified, `systemctl` will connect to and operate on the per-user systemd instance for the current logged-in user, rather than the global system instance.

--system
    This is the default. Explicitly tells `systemctl` to connect to and operate on the main system-wide systemd instance.

DESCRIPTION

The `systemctl cat` command provides a comprehensive view of how the systemd init system interprets a specific unit file. Unlike merely displaying the content of a single `.service` or `.target` file, `systemctl cat` intelligently aggregates the primary unit file with all its associated drop-in files. Drop-in files are typically found in subdirectories named `unit_name.d/` (e.g., `foo.service.d/override.conf`) and are used to extend or modify the unit's configuration without altering the original file.

This makes `systemctl cat` an invaluable tool for debugging and understanding the effective configuration of a systemd unit. It presents the consolidated content as a single, unified text, showing exactly what systemd reads and applies, thus resolving potential ambiguities arising from fragmented configurations across multiple files. This command is crucial for administrators to grasp the full scope of a unit's behavior, especially in complex environments where configurations are layered or customized.

CAVEATS

Permissions: To view system units, appropriate permissions are required, typically `root` privileges. User units can be viewed by the user who owns them.
Static Content: This command displays the parsed textual configuration. It does not reflect the dynamic runtime state, status, or any variables resolved at runtime by systemd.
Read-Only View: `systemctl cat` provides a read-only view. It does not validate the syntax or semantic correctness of the unit file content.

<B>UNDERSTANDING DROP-IN FILES</B>

Systemd unit files can be extended or overridden by so-called "drop-in" files. These are small configuration snippets located in `unit_name.d/` directories (e.g., `/etc/systemd/system/nginx.service.d/override.conf`). `systemctl cat` is essential because it presents the combined content of the main unit file and all relevant drop-ins, giving a complete picture of the unit's configuration that would be impossible to deduce by just looking at the primary unit file alone.

<B>DEBUGGING UNIT CONFIGURATIONS</B>

When a systemd unit behaves unexpectedly, its configuration might be spread across multiple files or subtly overridden by drop-ins. `systemctl cat` offers a powerful debugging advantage by showing the merged configuration. This allows administrators to quickly identify unintended overrides, missing directives, or incorrect settings that collectively define the unit's behavior, helping to diagnose and resolve issues efficiently.

HISTORY

The `systemctl cat` subcommand emerged as a necessary feature within the broader `systemctl` framework, which itself is the primary control interface for `systemd`. `systemd` was developed to replace traditional Unix `init` systems, introducing advanced features like parallelization, dependency management, and socket activation. The concept of drop-in files (`.d/*.conf`) was a key innovation allowing flexible unit customization without direct modification of vendor-provided unit files. This layering, while powerful, could make it difficult to ascertain the final, effective configuration. `systemctl cat` was specifically introduced to address this challenge, providing a transparent way for administrators and developers to see the complete, consolidated unit definition as interpreted by `systemd`, significantly aiding in troubleshooting and configuration management.

SEE ALSO

systemctl(1), systemd.unit(5), systemd.service(5), systemd.target(5), journalctl(1), cat(1)

Copied to clipboard