« Back to Systemd: Frequently Asked Questions

How to see the dependencies of a systemd unit

How to see the dependencies of a systemd unit?

Run systemctl with the 'list-dependencies' subcommand and service.

systemctl list-dependencies ssh.service

The systemctl command can be used to show dependencies between units with the list-dependencies subcommand. A nicely human-readable output will be displayed showing the selected unit, followed by the dependencies that rely on this unit. This is useful when a unit is in a failed state due to a dependency on another unit.

Usage

To see which units require the multi-user target to be active:

# systemctl list-dependencies multi-user.target
multi-user.target
● ├─apport.service
● ├─console-setup.service
● ├─cron.service
● ├─dbus.service
○ ├─dmesg.service
○ ├─e2scrub_reap.service
○ ├─grub-common.service
○ ├─grub-initrd-fallback.service
○ ├─irqbalance.service
<snip>

Want to move up the other way and see on which our unit requires? Add the --reverse option.

# systemctl list-dependencies --reverse multi-user.target
multi-user.target
● └─graphical.target

For automated processing or just plaintext output, use the --property option.

# systemctl show --no-pager --value --property="Wants" multi-user.target
lxd-agent.service ubuntu-advantage.service snapd.recovery-chooser-trigger.service e2scrub_reap.service snap-core20-2264.mount snap.lxd.activate.service apport.service <snip>

Interesting keywords to use as the property are:

  • After
  • Before
  • ConflictedBy
  • Conflicts
  • RequiredBy
  • Requires
  • WantedBy
  • Wants

Learn more about systemctl

This article uses the systemctl command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: systemctl

systemctl cheat sheet

Other questions related to Systemd

Related articles

Like to learn more? Here is a list of articles within the same category or having similar tags.

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

Mastodon icon