LinuxCommandLibrary

systemctl-show

Show systemd unit properties

TLDR

Show properties of the system service manager

$ systemctl show
copy

Show properties of the user service manager
$ systemctl show --user
copy

Show properties of a specific unit
$ systemctl show [unit]
copy

Show properties of a specific user unit
$ systemctl show [unit] --user
copy

Include empty properties in the list
$ systemctl show [[-a|--all]]
copy

Only show the specified properties
$ systemctl show [unit] [[-p|--property]] [Wants,Conflicts,...]
copy

SYNOPSIS

systemctl show [OPTIONS...] [UNIT...]

PARAMETERS

--all, -a
    Show all properties, including those that are unset or empty. By default, systemctl show only displays properties that have a value set.

--property=NAME, -p NAME
    Display specific unit properties. This option can be specified multiple times to show several properties. Property names are case-sensitive (e.g., ActiveState, Description, ExecStart).

--value, -l
    Print only property values. When used, the output will only contain the value of the property, without the "Name=" prefix. This option implies --plain for cleaner output, making it ideal for scripting to extract single values.

--json=MODE
    Output in JSON format. The MODE can be pretty for a human-readable, indented JSON output or short for a compact JSON format, which is more suitable for programmatic parsing.

UNIT...
    One or more unit names (e.g., nginx.service, network.target) whose properties are to be displayed. If no unit is specified, properties of the systemd manager itself (PID 1 for the system instance) are shown.

--system
    Operate on the system manager. This is the default behavior when running systemctl as root or with `sudo`.

--user
    Operate on the user's systemd manager instance. Each logged-in user typically runs their own systemd manager for user-specific services.

--host=HOST, -H HOST
    Operate on a remote host. Connects to the systemd manager on the specified host via SSH or other configured transport.

--machine=CONTAINER, -M CONTAINER
    Operate on a local container. Connects to the systemd manager of a specific local container, identified by its machine name.

DESCRIPTION

systemctl show is a crucial diagnostic and inspection command within the systemd ecosystem. It's used to retrieve and display the intricate properties of one or more systemd units (services, sockets, devices, mounts, etc.). Unlike systemctl status, which provides a concise human-readable summary, show outputs a comprehensive, machine-readable list of all configured properties and their current values for a given unit. This makes it invaluable for advanced troubleshooting, scripting, and deep dives into unit configurations and runtime states.

It can display properties like LoadState, ActiveState, SubState, Description, dependency relationships (After, Before, Requires, Conflicts), execution commands (ExecStart), resource controls (CPUShares, MemoryLimit), and many more, offering a granular view of how a unit is configured and behaves. Users can specify particular properties to view or list all of them, with options to format the output for easier parsing by scripts.

CAVEATS

  • The output of systemctl show is primarily designed to be machine-readable, which can make it less intuitive for quick human inspection compared to commands like systemctl status.
  • Property names are case-sensitive. Specifying ActiveState is correct, but activestate will not work.
  • Many properties are dynamic and reflect the current runtime state, while others are static configuration values defined in unit files.
  • Parsing the plain key=value output without --json requires careful scripting to handle potential multi-line values, special characters, or embedded equals signs in values.

INTERPRETING PROPERTIES

The properties displayed by systemctl show directly correspond to settings defined in unit files (e.g., systemd.service(5), systemd.target(5)) and their current runtime status. Understanding these property names requires familiarity with systemd unit file syntax and semantics. This command is often the first step in debugging complex unit behavior.

DEFAULT UNIT WHEN NONE SPECIFIED

If no unit is specified with systemctl show, it defaults to showing properties of the systemd manager itself (the init process, PID 1, for the system instance). This can provide valuable insights into the overall systemd environment, its capabilities, and its general state.

SCRIPTING EXAMPLE

For reliable scripting, using --value or --json is highly recommended.

To get only the active state of a service:
systemctl show --property=ActiveState --value nginx.service
This would output just "active" if the Nginx service is running, or "inactive" otherwise.

To get multiple properties in JSON:
systemctl show --property=Description --property=ExecMainStartTimestamp --json=pretty nginx.service
This would provide a structured JSON output of the specified properties, making it easy to parse with tools like jq.

HISTORY

The systemctl command is the primary control interface for systemd, which revolutionized Linux initialization by replacing the traditional SysVinit system in many distributions starting in the early 2010s. The show subcommand has been an integral part of systemctl since its inception, providing a consistent and programmatic way to inspect unit configurations and states. This functionality was less directly available or standardized with older init systems. Its design reflects systemd's emphasis on introspection, API-driven management, and providing detailed information for system administrators and developers.

SEE ALSO

systemctl(1), systemctl status(1), systemctl list-units(1), journalctl(1), systemd.unit(5), systemd.service(5), systemd.target(5)

Copied to clipboard