How to list package dependencies in Linux on any distribution

  • Knowing the dependencies of a package helps avoid installation errors and problems when updating or removing software.
  • Tools such as apt-cache, dpkg-deb, rpm, yum, zypper or pactree allow you to list dependencies in the main distributions.
  • It is possible to prepare offline installations by previously downloading packages and their dependencies from computers with internet access.
  • Additional utilities such as aptitude, debfoster, or dselect facilitate advanced package management and the cleanup of orphaned dependencies.

Listing package dependencies in Linux: commands and practical examples

When you install software on GNU/Linux, the Package dependencies can be your best friend or your worst nightmareKnowing which additional libraries and packages a program needs is key to avoiding errors, incomplete installations, and broken systems, especially if you work offline or on production servers.

In this article we will look at, in detail and in the most practical way possible, How to list the dependencies of a package in Linux on different distributionsWe'll cover Debian/Ubuntu (DEB), Fedora/RHEL/CentOS (RPM), Arch Linux, openSUSE, and how to find out which libraries a given binary uses. We'll also review useful package management commands to help you better understand what's happening behind the scenes when you install something.

Why are you interested in knowing the dependencies of a package?

In any modern distro, package managers like apt, dnf, yum, pacman, or zypper are capable of automatically resolve most dependenciesYou request to install a program, and they pull in everything necessary. However, there are several scenarios where it's vital to see those dependencies explicitly.

For example, if you often test new software, compile applications, or manage servers, you'll be interested to know How to set up a development environment and what other components will be installed, what takes up space, and what might break existing components. This helps you avoid version conflicts, duplicate libraries, or packages you don't want on your system.

The situation of working is also very common. No internet connection or with isolated machines. In those cases, you need to be able to download all the dependencies at once to a networked machine and then transfer them via USB to the disconnected machine, instead of going through a trial-and-error process, noting broken dependencies one by one.

Another important point is long-term maintenance: knowing the dependencies helps you to detect packages that were only installed as a requirement of others and that are no longer needed, clean up the system and reduce the attack surface and potential conflicts, for example by configure a lightweight desktop environment.

The situation of working is also very common. No internet connection or with isolated machines. In those cases, you need to be able to download all the dependencies at once to a networked machine and then transfer them via USB to the disconnected machine, instead of going through a trial-and-error process, noting broken dependencies one by one.

Another important point is long-term maintenance: knowing the dependencies helps you to detect packages that were only installed as a requirement of others and that are no longer needed, clean up the system and reduce the attack surface and potential conflicts.

List dependencies in Debian-based distributions (DEB)

In the Debian ecosystem and its derivatives (Ubuntu, Linux Mint, Elementary OS, and others) we have several very powerful tools for managing and check the dependencies of a packagewhether it's already installed or you only have the .deb file.

View dependencies from repositories with apt-cache

Listing dependencies of a package in Linux

If the package is in the repositories configured on your system, the most direct way to check what it needs is to use apt-cache depends package_nameThis command queries the APT database and shows you the list of packages that the target package depends on, as well as suggested and recommended packages.

For example, to see vim's dependencies on Debian or Ubuntu, you can run something like apt-cache depends on vim and you will get a list with lines like “Depends:” and “Suggests:”, indicating which packages are essential and which are optional or recommended.

Equally useful is the command apt-cache rdepends package_nameThis is useful for seeing the inverse relationship: what other packages depend on it. This is key when you're considering uninstalling something and want to check. What would you break or what would be eliminated in a cascading fashion? if you remove it.

If you want to delve a little deeper, you can take a look at the quick help with apt-cache –help or go directly to the detailed documentation with man apt cache, where you will see options such as show, pkgnames, stats or unmet to check statistics, unresolved dependencies or detailed information about a package.

View dependencies of a loose .deb file with dpkg-deb

When what you have is a .deb package downloaded manually (for example from a website or another computer) and it is not yet installed, you can read its internal information without installing it using the command dpkg-deb -I package_name.deb.

This command displays the package metadata, including the field Depends:This document contains the exact list of packages that must be present (and in what version ranges) for the installation to be successful. This way you can quickly identify what you need to download in addition to the main package.

Imagine you want to know what a package needs, like python-glade2_2.13.0-0ubuntu8_i386.debWhen you run `dpkg-deb -I` on it, you'll see something like "Depends: python (<< 2.6), python (>= 2.4), python-support (>= 0.7.1)... etc.", which clearly indicates all the parts that should already be installed or that you will need to get.

Download packages without installing them using aptitude

To complete the job when you're preparing an offline installation, this will come in very handy. Download .deb files without installing them.Tools like aptitude make it very easy to do with the command aptitude download package_name.

So, if you run something like aptitude download vlcThe system will download the VLC .deb file to your current directory without adding it to the system. Combining this with reading dependencies using dpkg-deb, you can gather the entire set of necessary packages in a single trip with your USB, avoiding the classic cycle of "install - a dependency is missing - note the name - download again".

In addition to download, aptitude provides a host of options geared towards advanced package and dependency management: aptitude search to search by name, aptitude show to see details, aptitude why y aptitude why-not to explain why a specific package should (or cannot) be installed, or the simulation of installations with aptitude -rsvW install package to check what would happen without touching anything.

Check dependencies and packages with dpkg, apt-get, and dselect

The basic tool in Debian systems is dpkgwhich handles individual packages. Although it doesn't resolve dependencies on its own, it offers options such as dpkg -I To view information about an uninstalled .deb package, dpkg -l to list installed packages or dpkg -L to see which files a specific package installs.

For its part, apt-get It's the classic APT front-end that lets you install, update, and remove packages along with their dependencies. Commands like apt get install, apt-get upgrade, apt-get dist-upgrade o apt get check They handle dependency resolution and even allow for the simulation of installations with -s to see what would happen without implementing any real changes.

Another veteran but powerful tool is dselectIt offers an interactive text interface for browsing packages, selecting what to install or remove, and managing dependencies more visually. Although less commonly used today, it remains an option for those who prefer menus and lists to memorizing commands.

Clean up orphaned packages with debfoster

Over time, it is very common for them to accumulate. packages installed only as dependencies of programs you've already removed. For this type of cleanup on Debian-based systems, there's a very interesting tool called debfoster.

Its idea is simple: when you run it, it shows you a list of packages that have not been marked as "manually installed" and asks you one by one if you want to keep them or not, allowing you to respond with yes (y), no (n), help (h) or more information (?).

As you answer, debfoster saves your decisions in its own databaseThis prevents it from asking you for the same packages again in future runs. It's a practical way to keep your system free of unnecessary "clutter," always taking care not to delete anything that's still truly useful.

List dependencies in RPM-based distributions (Fedora, RHEL, CentOS…)

In the RPM world (Fedora, Red Hat Enterprise Linux, CentOS, Scientific Linux, AlmaLinux, Rocky, etc.), the logic is similar but the tools differ. Again, let's distinguish between Packages installed from repositories and loose .rpm files.

Use rpm to view dependencies

The basic utility in these systems is rpmwhich allows you to install, update, remove, and query packages. For our purposes, we're most interested in the query function with the option -q and, in particular, its dependency-related variants.

If you want to see what a package already installed or available in the system database depends on, you can use rpm -qR package_nameThat command will show the package requirements, that is, the libraries and other packages that must be present for it to work properly.

When you have a local .rpm file that hasn't been installed yet, the syntax is practically the same, but adding the option -p To indicate that you are going to consult a file: rpm -qpR .rpm fileThis way you'll see its dependencies without needing to install anything.

In addition to -qR, rpm has many other relevant actions for package management, such as -i to install, -U to update or install if it doesn't exist, -F To update, only update if a previous version is already available. -e to uninstall, -V to check the -K to check the integrity of the package.

Resolve and list dependencies with yum and dnf

High-level managers rely on RPMs, such as yum and, in more modern systems, dnfThese tools do automatically resolve dependencies and offer commands to check them quite conveniently.

With yum, for example, you can use yum deplit package_name To show the dependencies of a specific package, as resolved by the package manager in its repositories. It is also possible to check which package provides a given dependency with yum provides o yum whatprovides, very useful when you know the name of a library but not the name of the package that contains it.

In addition to installing (yum install), update (yum update o upgrade), eliminate (yum remove or once upon a time), search (yum search) or list information (yum info, yum list), the command yum resolvedep allows to display which packages satisfy a specific dependencywhich is perfect for understanding how the pieces fit together.

In terms of comparisons, you might think that yum install It is essentially equivalent to a rpm -ivh o rpm -Uvh but with automatic dependency resolution; that yum remove corresponds to rpm -eor that yum info It gives you similar information to rpm -qiIn many situations, using yum (or dnf, in more recent distros) is simply more convenient and safer than interacting only with rpm.

List dependencies in Arch Linux and derivatives (pacman, pactree)

Listing dependencies of a package in Linux

If you work with Arch Linux or Arch-based distributions like Manjaro or EndeavourOS, you're probably already familiar with it. pacman as a package manager. What's interesting in this context is that pacman includes an extra tool called pactree, designed specifically to produce dependency trees.

The command pactree package_name It generates a hierarchical diagram of the package's dependencies, represented textually as a tree. This allows you to see everything at a glance. what depends on what and how relationships are linkedfollowing each branch to the end.

For example, when you run something like pactree vim, you'll see vim at the top and, below it, lines with symbols indicating the packages it depends on, these in turn with their own dependencies, and so on, even showing cases where multiple dependencies overlap or are provided by alternative libraries.

The tool has different options for modifying the output, but in most cases simply using `pactree package_name` is more than enough. Understanding the dependency structure of a package in ArchFor advanced details, you can always refer to the documentation. man pactree.

List dependencies in SUSE and openSUSE (zypper)

In systems like SUSE and openSUSE, the reference package manager is zypperwhich also allows you to directly view the dependencies of a package, both at the installation and information level.

If you want to check what a specific package requires, you can run something like zypper info –requires package_nameThat command will display the usual zypper information about the package (version, repository, description, etc.) along with the list of dependencies necessary for its operation.

In this way, just like with apt-cache or rpm -qR, you have a clear view of the additional libraries and packages that should be on the system, and you can anticipate potential problems or prepare installations on offline machines.

Viewing the dependencies of a binary file with ldd

So far we've talked about package-level dependencies, but often you'll want to go a step further and see which dynamic libraries does a specific binary usewhether it's a system executable, a program you've compiled yourself, or a file someone has passed to you.

That's what the command is for. ldd binary_file, which analyzes the binary and displays the list of shared libraries that it loads at runtime, along with the path of each one and the memory address where it is linked.

If you need more details, you can use ldd -v binary_file to obtain additional information, including the dependencies of the loaded libraries themselves. It is a very useful tool for diagnosing “library not found” errors, problems with incompatible versions, or simply to understand exactly what a program is using under the hood.

Install packages and dependencies without an internet connection

One case that remains quite common is that of those who need Installing programs on machines without internet accessWhether it's due to security, network restrictions, or simply because there's no connection available, there are several tricks in Debian/Ubuntu environments that can make your life easier.

On the one hand, everything you download and install on a connected system is usually saved in / Var / cache / apt / archivesThis means that if you install a package like VLC on a computer with internet access... sudo aptitude install vlcThe main package and all its dependencies will be stored in that cache directory.

If you copy the contents of /var/cache/apt/archives to a USB drive, you can take it to the machine without internet access, paste all the .deb files into a folder, and run sudo dpkg -i * .deb to try installing them all at once. Sometimes it will work the first time, sometimes it won't; but at least you'll already have most of the necessary parts locally.

The least pleasant part of this method is that the typical message often appears. “unmet dependency” Installing a .deb file often involves returning to a computer with an internet connection, downloading any missing components, and repeating the process. To minimize these back-and-forths, tools like dpkg-deb -I, apt-cache depends, and aptitude download are invaluable.

Another interesting tool that simplified this scenario was aptonCDcapable of generating a local repository with all downloaded packages and then transferring it to another machine (for example, on a CD or DVD) and using it as an installation source, drastically reducing manual work with USBs.

Summary of key commands for managing packages and dependencies

In addition to the specific commands for listing dependencies, it is useful to have an overall view of the most useful commands for managing packages in the main systemsBecause often the problem is not just seeing what depends on what, but also installing, updating, cleaning, or verifying that everything is in order.

On Debian/Ubuntu systems, dpkg It offers commands such as dpkg -i package.deb to install or update, dpkg -r o -P to eliminate, dpkg -l to list packages, dpkg -s to see information about a specific one, dpkg -L to list the files it installs or dpkg -S to find out which package a system file belongs to.

On the APT plan, apt-get y apt-cache They are complemented by commands to install and update (install, upgrade, dist-upgrade), clean the cache (clean, autoclean), check dependencies (apt get check) and obtain lists of packages or statistics about the database.

In the RPM world, rpm It handles basic operations (installing, updating, uninstalling, verifying, querying information), while yum and dnf provide a layer of convenience for resolve dependencies automatically, search for packages, list information, and work with remote repositories.

Lastly, tools like aptitude, dselect, debfoster, zypper or pactree They complete the arsenal for having fine control over what is installed, what is deleted, what is superfluous in the system, and how the different packages and libraries relate to each other.

With all these commands in hand, the task of List the dependencies of a package in Linux and understand what is happening each time you install or remove software It ceases to be a mystery and becomes a controlled process, even when you work offline or in sensitive environments where you cannot afford improvisation.

Linux file attributes
Related article:
Linux post-installation script: how to automate your system after formatting