33
systemctl list-dependencies postgres

Will list all the dependencies of the postgres service. How do I find all the dependents of a service (or unit, or target)?

3
  • 12
    Are you looking for the --reverse flag? Commented Feb 5, 2018 at 18:54
  • Yes, I just spotted it in the manpage and was about to answer my own question. I ran a few tests, most of them add up. It seems to be what I was looking for.
    – Rolf
    Commented Feb 5, 2018 at 19:15
  • However it is not exactly what I wanted. It seems that it will only list dependents that are explicitly declared with "RequiredBy", "WantedBy", etc.
    – Rolf
    Commented Feb 5, 2018 at 19:24

1 Answer 1

37
$ systemctl list-dependencies systemd-sysusers.service --all --reverse
systemd-sysusers.service
● └─sysinit.target
●   ├─accounts-daemon.service
●   │ └─graphical.target
●   ├─acpid.path
●   │ └─paths.target
●   │   └─basic.target
●   │     └─multi-user.target
●   │       └─graphical.target

man systemctl:

   list-dependencies [UNIT...]
       Shows units required and wanted by the specified units.
       This recursively lists units following the Requires=,
       Requisite=, ConsistsOf=, Wants=, BindsTo= dependencies. If
       no units are specified, default.target is implied.

       By default, only target units are recursively expanded.
       When --all is passed, all other units are recursively
       expanded as well.

       Options --reverse, --after, --before may be used to change
       what types of dependencies are shown.

       Note that this command only lists units currently loaded
       into memory by the service manager. In particular, this
       command is not suitable to get a comprehensive list at all
       reverse dependencies on a specific unit, as it won't list
       the dependencies declared by units currently not loaded.
1
  • 2
    Would a sudo systemctl daemon-reload help to remedy the "... as it won't list the dependencies declared by units currently not loaded" argument ?
    – cueedee
    Commented Sep 14, 2023 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .