This guide shows you how to use systemctl list-dependencies on Red Hat Enterprise Linux to see the full dependency tree of a systemd unit (like a service or target). You’ll learn how to read the output, filter it, and troubleshoot common issues. No prior systemd knowledge is required, but basic comfort with the command line is assumed.
What You’ll Need
- Access to a RHEL system (version 7 or later, though 8/9 are most common).
- A user account with
sudoprivileges (some commands require root). - A terminal emulator (GNOME Terminal, Konsole, or SSH session).
Step-by-Step
- Open a terminal. If you’re on the graphical desktop, press
Ctrl+Alt+Tor find Terminal in the applications menu. If you’re SSH’d in, you’re already there. - Check the status of a unit (optional but helpful). Run
systemctl status sshdto confirm the unit name and that it’s loaded. Replacesshdwith any unit you care about (e.g.,firewalld,crond,multi-user.target). - List dependencies for a unit. Run the basic command:
systemctl list-dependencies sshd. This shows a tree of all units thatsshddepends on (its “requires” and “wants” dependencies). The output uses indentation and box-drawing characters to show the hierarchy. - Include reverse dependencies. To see what depends on
sshd(i.e., units that pull it in), add the--reverseflag:systemctl list-dependencies --reverse sshd. - Expand all dependencies. By default, the tree only shows the immediate dependencies of each unit. To see the full recursive tree, use
--all:systemctl list-dependencies --all sshd. This can be very long, so pipe it tolessto scroll:systemctl list-dependencies --all sshd | less. - Filter by dependency type. Use
--type=to show only specific types (e.g.,requires,wants,after). For example:systemctl list-dependencies --type=wants sshdshows only “wants” dependencies. You can combine multiple types with commas:--type=requires,wants. - Filter out target units. Targets are like runlevels (e.g.,
multi-user.target). To hide them and focus on actual service/device/mount units, use--no-pagerwithgrep:systemctl list-dependencies --no-pager sshd | grep -v '.target'. Or use the--plainflag to remove the tree characters for easier parsing:systemctl list-dependencies --plain sshd. - Check a target (e.g., default boot target). To see what services start at boot, use:
systemctl list-dependencies default.target. This is a great way to audit which services are enabled. - Use with grep to find a specific unit. To quickly check if a particular unit is in the dependency tree, run:
systemctl list-dependencies --all sshd | grep 'network'. This will show any line containing “network”. - Save output to a file. Redirect the output for later analysis:
systemctl list-dependencies --all sshd > deps.txt. Then open withless deps.txt.
Common Mistakes
- Forgetting the unit suffix. Unit names often have a suffix like
.service,.target,.socket. If you typesshdwithout the suffix, systemd usually finds it, but for custom units you must include the full name (e.g.,myapp.service). - Misreading the tree. The output shows a tree, but not every line is a direct dependency. A line with a box-drawing character (like
├─or└─) is a child of the previous unit. A line with just spaces is a continuation of the previous branch. Use--plainto avoid confusion. - Assuming all dependencies are started.
list-dependenciesshows the dependency graph, not the current state. A unit may be listed but not active. Check withsystemctl statusfor actual state. - Using
--typeincorrectly. The--type=flag expects dependency types likerequires,wants,after,before,conflicts. It does not accept unit types likeserviceortarget. To filter by unit type, usegrepinstead. - Not using
--allwhen needed. By default, the command only shows one level of dependencies for each unit. If you want the full recursive tree, you must add--all, otherwise you’ll miss many dependencies.
Tips
- Combine with
systemctl list-units. To see which dependencies are actually loaded and active, runsystemctl list-units --type=service --state=runningand compare with the dependency list. - Use
--no-pagerfor scripting. When piping togrepor a file, add--no-pagerto avoid the pager interfering. - Understand the difference between
requiresandwants.requiresmeans the unit will fail if the dependency fails;wantsmeans the dependency is started if possible, but the unit will not fail if it’s not available. This is crucial for troubleshooting. - Check the
After=andBefore=dependencies. These are ordering dependencies, not hard requirements. They control the order of startup, not whether a unit starts. You can see them withsystemctl show -p After -p Before sshd. - Use
systemd-analyzefor timing. If you’re investigating slow boot,systemd-analyze blameandsystemd-analyze critical-chainare more useful thanlist-dependencies.
Troubleshooting
- Command not found. If you get
bash: systemctl: command not found, you’re likely not on a systemd-based system. RHEL 7+ uses systemd, but if you’re on an older version (RHEL 6 or earlier), you’ll usechkconfigandserviceinstead. Upgrade or use the appropriate commands. - Unit not found. If you see
Unit sshd.service not found., the unit name is wrong or the unit is not installed. Usesystemctl list-unit-files | grep sshto find the exact name. - Permission denied. Some units (especially system-level ones) may require root to list dependencies if they’re not world-readable. Use
sudo systemctl list-dependencies sshdto run with elevated privileges. - Output is too long. The full tree for a complex service like
graphical.targetcan be hundreds of lines. Use--plainand filter withgrep, or save to a file and open in an editor. - Dependencies show as “not-found”. If you see lines like
● foo.service - not-found, it means the dependency is listed but the unit file is missing. This often happens after a package is removed. Check withsystemctl status foo.serviceand reinstall the package if needed. - Tree is not expanding. If you only see one level and not the full tree, you forgot
--all. Add it and try again.
Frequently Asked Questions
What is the difference between requires and wants dependencies?
requires is a hard dependency: if the required unit fails to start, the unit that requires it will also fail. wants is a soft dependency: the wanted unit is started if possible, but if it fails, the dependent unit still starts.
How do I see only the dependencies that are actually enabled?
Use systemctl list-dependencies --all --state=active to show only dependencies that are currently active (loaded and running). This filters out disabled or failed units.
Can I list dependencies for a socket or timer unit?
Yes, the command works for any unit type. For example, systemctl list-dependencies sshd.socket or systemctl list-dependencies backup.timer.
Why does list-dependencies show targets like multi-user.target?
Targets are logical groups of units. Services often have a dependency on a target to ensure they start at the right time during boot. It’s normal to see them in the tree.
How can I see the dependency tree in a more readable format?
Use --plain to remove the tree characters and --no-pager to avoid paging. Then you can sort or filter with standard text tools like sort or grep.
Does this command work on RHEL 7, 8, and 9?
Yes, systemctl list-dependencies is available in all RHEL versions that use systemd, which is RHEL 7 and later. The output format is consistent across these versions.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Spotify Jam Not Working on Mobile? Fixes That Work
- Windows 10 No Internet Secured WiFi Error Fix
- Multi-Cloud GPU Failover Design Guide
- Error Code Currant Destiny? Meaning & Fixes
- AirPlay with Roku Multi-Device Setup: A How-To
- How to Set a Timer on iPhone (iOS 18 & 17)