LinuxCommandLibrary

systemctl-list-dependencies

List systemd unit dependencies

TLDR

Show the dependency tree of default.target

$ systemctl list-dependencies
copy

Show the dependency tree of a specific unit
$ systemctl list-dependencies [unit]
copy

Include all dependency types (not only Requires= and Wants=)
$ systemctl list-dependencies [unit] [[-a|--all]]
copy

Limit the tree to a specific unit type
$ systemctl list-dependencies [unit] [[-t|--type]] [service|socket|target|mount|...]
copy

Reverse the direction to show units that depend on the specified unit
$ systemctl list-dependencies [unit] --reverse
copy

Print output without headers or footers (for scripts)
$ systemctl list-dependencies [unit] --no-legend
copy

SYNOPSIS

systemctl list-dependencies [OPTIONS...] [UNIT...]

PARAMETERS

UNIT
    Specifies the unit(s) for which to list dependencies. If omitted, default.target is typically used as the default unit.

--all, -a
    Shows all types of dependencies, including 'Conflicts=', 'Before=', 'After=', etc., not just 'Wants=' and 'Requires='.

--recursive
    Recursively shows dependencies for all units found. This is the default behavior for most dependency types unless --plain is used without a specific dependency type.

--reverse, -r
    Lists units that depend on the specified unit, rather than units it depends on.

--after
    When used with --reverse, shows units that have 'Before=' dependencies on the specified unit. When used without --reverse, implies 'After=' and 'Requires='/'Wants=' dependencies.

--before
    When used with --reverse, shows units that have 'After=' dependencies on the specified unit. When used without --reverse, implies 'Before=' and 'RequiredBy='/'WantedBy=' dependencies.

--plain
    Outputs results in a plain, non-graphical format, without colors or indentation. This is useful for scripting and parsing the output programmatically.

--property=PROPERTY
    Filters the output to show only dependencies of a specific property type (e.g., Wants, Requires, After, Conflicts). This option implies --plain.

DESCRIPTION

The systemctl list-dependencies command is a powerful utility within systemd for visualizing and understanding the intricate dependency relationships between systemd units. It helps administrators and developers comprehend why certain services start before others, or what other units are required for a specific service to function correctly. By default, it shows 'Wants=' and 'Requires=' type dependencies for a specified unit, presenting them in a clear, hierarchical tree structure. This output is invaluable for debugging startup issues, optimizing service configurations, or simply gaining a deeper insight into the system's initialization process.

It can also be used to explore reverse dependencies, showing which units rely on a particular service, making it essential for impact analysis before modifying or stopping critical system components. Understanding these relationships is fundamental to managing a systemd-powered Linux environment effectively.

CAVEATS

The output of list-dependencies can be very extensive, especially when using --all or analyzing fundamental units like sysinit.target. The tree visualization can become complex and difficult to parse visually for deep dependency chains. Keep in mind that 'Wants=' dependencies are typically weak and non-critical, meaning the unit will still attempt to start even if the wanted unit fails or is not present, unlike 'Requires=' dependencies which are strong.

UNDERSTANDING OUTPUT

The output typically shows a hierarchical tree structure. Units marked with a green dot (●) are generally active and running, while units with a white dot (○) are inactive or dead. The indentation indicates the dependency level. Different dependency types (e.g., 'Wants', 'Requires', 'After') are not explicitly labeled in the default tree view but are implicitly understood based on the direction of dependency (forward or reverse) and the options used.

PRACTICAL USE CASES

Use systemctl list-dependencies multi-user.target to see what services start with your graphical or console login environment. Use systemctl list-dependencies --reverse sshd.service to find out which other services or targets might rely on the SSH daemon. This is crucial when planning maintenance, troubleshooting startup failures, or understanding the impact of stopping core services.

SEE ALSO

systemctl(1), systemd.unit(5), systemd.target(5), systemd.service(5), systemd.directives(7)

Copied to clipboard