LinuxCommandLibrary

systemctl-list-units

List all loaded systemd units

TLDR

List units which are active, have pending jobs, or have failed

$ systemctl list-units
copy

List all units, including inactive ones
$ systemctl list-units [[-a|--all]]
copy

Filter by unit type
$ systemctl list-units [[-t|--type]] [service|socket|timer|...]
copy

Filter by state
$ systemctl list-units --state [running|listening|dead|...]
copy

Filter by a name pattern
$ systemctl list-units 'systemd*'
copy

Print output directly to stdout
$ systemctl list-units --no-pager
copy

Print output without headers or footers (for scripts)
$ systemctl list-units --no-legend
copy

SYNOPSIS

systemctl list-units [OPTIONS...] [PATTERN...]

PARAMETERS

-t , --type=
    Filters units by one or more specified types (e.g., service, socket, target). Multiple types can be comma-separated.

-a, --all
    Shows all loaded units, regardless of their active state (including inactive, failed, activating, or deactivating units).

--state=
    Filters units by one or more specific active states (e.g., active, inactive, failed, activating, deactivating). Can be specified multiple times.

--failed
    A convenient shortcut for --state=failed, displaying only units that are in a failed state.

-p , --property=
    Displays only the specified unit properties, such as ActiveState, LoadState, SubState, etc. Multiple properties can be comma-separated.

--full
    Prevents truncation of unit names in the output, showing the complete name.

--plain
    Generates plain, unformatted output suitable for scripting, without colors, headers, or lines.

--no-legend
    Suppresses the column header line in the output.

--no-pager
    Forces output directly to stdout without piping through a pager like less.

--reverse
    Reverses the default sorting order of units.

--output=
    Specifies the output format, such as short, full, json, json-pretty, export.

PATTERN...
    One or more unit name patterns to filter the output. Wildcards (*) are supported.

DESCRIPTION

The systemctl list-units command is a core component of Systemd, the init system used by most modern Linux distributions. It provides a comprehensive overview of all currently loaded units in the system. Units represent various Systemd objects like services, sockets, devices, mount points, and timers. This command is essential for administrators and users to quickly ascertain the state, activity, and sub-state of these units, aiding in system monitoring, diagnostics, and troubleshooting. By default, it displays only active units, presenting information such as their load state, active state, sub-state, and a brief description. The output is typically paginated for readability, showing columns like UNIT, LOAD, ACTIVE, SUB, and DESCRIPTION. Various options allow users to filter the results by type, state, or pattern, making it a flexible tool for pinpointing specific units or getting a broad system overview.

CAVEATS

The list-units command only displays units that Systemd has loaded into memory. It does not list all available unit files on the filesystem. For a comprehensive list of all unit files, use systemctl list-unit-files.

While list-units itself generally does not require root privileges, obtaining detailed status for certain sensitive units or modifying them via other systemctl subcommands often does.

UNDERSTANDING OUTPUT COLUMNS

The default output of systemctl list-units provides several key columns:
UNIT: The full name of the Systemd unit.
LOAD: The load state of the unit. Common states are loaded (successfully parsed and loaded), not-found, or bad-setting.
ACTIVE: The high-level active state. Common states are active (running), inactive (not running), failed (unit failed to start or stopped unexpectedly), activating, or deactivating.
SUB: The low-level sub-state, more specific than ACTIVE. For services, this might be running, dead, exited, plugged, waiting, etc. This state varies greatly by unit type.
DESCRIPTION: A brief human-readable description of the unit.

COMMON USE CASES

Beyond general system overview, list-units is frequently used for:
- Troubleshooting: Identifying failed units using systemctl list-units --failed.
- Checking Service Status: Quickly seeing if a particular service is active (e.g., systemctl list-units | grep sshd).
- Filtering by Type: Examining only services with systemctl list-units --type=service or timers with systemctl list-units --type=timer.
- Scripting: Using --output=json or --plain for machine-readable output in scripts.

HISTORY

The systemctl command, including its list-units subcommand, was introduced as part of the Systemd project, which began development around 2010. Systemd aimed to replace the traditional SysVinit and Upstart init systems in Linux distributions. As Systemd gained widespread adoption (first by Fedora in 2011, then Debian, Ubuntu, RHEL, etc.), systemctl became the standard interface for managing services and other system resources. The list-units command has been a fundamental part of systemctl since its early days, providing a consistent and powerful way to inspect the state of the system's active units.

SEE ALSO

systemctl(1), systemctl status(1), systemctl list-unit-files(1), journalctl(1), systemd.unit(5), systemd.service(5), systemd.socket(5)

Copied to clipboard