1. Introduction

An RPM is a file container to install and update packages on Linux operating systems. These packages are used in many Linux distributions such as CentOS, Fedora, openSUSE, AlmaLinux, PCLinuxOS, OpenMandriva, and Oracle Linux.

Dependencies are packages that an RPM requires to function. Sometimes, we might need to check the dependent packages of the RPM and get some details — for example, the number of connections with other packages, sizes, or versions.

In this tutorial, we’re going to learn different ways to check RPM dependencies from the command line. As an example, we’re going to use the nano package.

2. Dependency List of RPM

If a package is installed, we can use the rpm command to achieve our goals. On the other hand, we use the yum or dnf commands if we haven’t installed the package yet.

2.1. Installed RPM

The rpm command manages packages. It can build, install, query, verify, update, and remove packages.

In this case, we’re going to get some info about an RPM:

$ rpm -qR nano
config(nano) = 5.6.1-5.el9
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsZstd) <= 5.4.18-1

Here, we use -q (–query) option along with the package name. Moreover, -R (–requires) lists what the package depends on.

2.2. Non-Installed RPM

We can use the yum or dnf commands if the RPM exists in the online or offline repo:

$ yum deplist nano
Last metadata expiration check: 0:01:50 ago on Wed 01 Mar 2023 11:32:17 AM UTC.
package: nano-5.6.1-5.el9.x86_64
  dependency: libc.so.6(GLIBC_2.34)(64bit)
   provider: glibc-2.34-60.el9.x86_64
  dependency: libmagic.so.1()(64bit)
   provider: file-libs-5.39-12.el9.x86_64
  dependency: libncursesw.so.6()(64bit)
   provider: ncurses-libs-6.2-8.20210508.el9.x86_64

The yum deplist option lists all the given package’s relations. In the result, we can see our selected package with the latest available version and the list of all related packages and providers.

3. Using the repoquery Tool

The repoquery tool is a program for querying info from a YUM repo. This program works for both installed and non-installed packages.

To use it, we can install it via yum or dnf:

$ yum install yum-utils

We should use –requires and –resolve with the repoquery command. Moreover, if we’re going to get info about an RPM file on our system, we use the full name of that file:

$ repoquery --requires --resolve nano-2.9.8-1.el8.x86_64.rpm 
Last metadata expiration check: 0:04:19 ago on Fri 03 Mar 2023 10:21:28 AM UTC.

This way, we don’t need it to be installed to extract the necessary data.

In addition, if we want to check the repo, we can just write the package’s name:

$ repoquery --requires --resolve nano
Last metadata expiration check: 0:00:10 ago on Fri 03 Mar 2023 10:21:28 AM UTC.

In this case, the nano package in the repo is the latest version. So, the result is different from the previous command, which deals with an older version.

4. Using the rpmreaper Tool

rpmreaper is an ncurses application that basically allows removing unnecessary packages and their connections from the system. Moreover, we can use this tool to see the RPM packages in a tree view.

To install rpmreaper, we can again use yum or dnf. However, on some Linux distros, we might first need to install the EPEL repo via the epel-release package:

$ yum install epel-release

Now, we can install rpmreaper:

$ yum install rpmreaper

At this point, we can simply run it to browse the RPM tree:

$ rpmreaper

rpm repeal
In the first column, we can see that every package has a flag (L, o, B):

  • L – leaf, meaning no other package depends on this one
  • o – part of a cycle
  • B – missing dependencies

To see the full list, we use the Up and Down arrow keys. Also, we can press the r key on a selected package to show its connections.

Besides, we can use the i key to see the full details of a package:

Name        : nano
Version     : 5.6.1
Release     : 5.e19
Architecture: x86_64
Install Date: Wed 01 Mar 2023 11:47:43 AM UTC
Group       : Unspecified
Size        : 2835120
License     : GPLv3+
Signature   : RSA/SHA256, Wed 11 Aug 2021 05:33:36 AM UTC, Key ID 05b555b38483c65d
Source RPM  : nano-5.6.1-5.el9.src.rpm
Build Date  : Tue 10 Aug 2021 01:16:05 AM UTC
Build Host  : X86-06.stream.rdu2.redhat.com
Packager    : [email protected]
Vendor      : CentOS
URI         : https://www.nano-editor.org
Summary     : A small text editor
Description :
GNU nano is a small and friendly text editor.

Now, we have a lot of info about our specified package. For example, we have the Licence, Signature, Original website, and above all, our package’s files in a list.

5. Using the rpmdep Tool

The rpmdep is an improved rpm -qR command that displays all connections of an installed RPM package. It’s a perl tool that is part of a package named rpmorphan.

First, let’s install perl and rpmorphan:

$ yum install perl rpmorphan

In CentOS, we should first download the package, then install it via the rpm command:

$ wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/r/rpmorphan-1.15-1.el7.noarch.rpm
$ rpm -ivh rpmorphan-1.15-1.el7.noarch.rpm

Now, we can simply use rpmdep.pl to check our package:

$ rpmdep.pl nano
nano depends upon basesystem,bash,centos-gpg-keys,centos-stream-release,centos-stream-repos,file-libs,filesystem,glibc,glibc-common,glibc-langpack-en,libgcc,ncurses-base,ncurses-libs,setup,tzdata,zlib

We also can check if a package has parents or is an orphan by using the -depending option:

$ rpmdep.pl -depending nano
nano is needed by default-editor, nano-default-editor

In this example, the nano package is not an orphan and it is needed by two packages.

6. Conclusion

In this article, we’ve reviewed different ways to check RPM dependencies from the command line. To sum up, depending on whether we want to check installed, non-installed, or downloaded RPMs, or how much info we need from packages, we can choose different ways accordingly.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.