« Back to Systemd: Frequently Asked Questions

How to see the dependencies of a systemd unit

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

Feedback

Is the described answer not working or incorrect, got another tip or question? Share your thoughts!