Skip to Content

3 ways to Check RPM package dependency in Linux

This article is part of the following series.

 

RPM packages can contain not only the software itself but also its dependencies, which are other software packages required for the software to function properly.

Managing RPM package dependencies is crucial to ensure the smooth installation and operation of the software on your Linux system.

Get Your Free Linux training!

Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!

In this post, we’ll explore how to check RPM package dependencies with different commands.

Check RPM package dependency with rpm command

The “rpm -qR” command is used in Linux systems to query the dependencies of a specified RPM package. This command only works when the RPM package is installed on the system.

The “-qR” options are used together to query the dependencies of an RPM package. Here’s what each option does:

  • “-q”: This option stands for “query” and is used to query information about an RPM package installed on the system.
  • “-R”: This option stands for “requires” and is used to display the dependencies required by an RPM package. It provides a list of other files that need to be installed on the system for the specified RPM package to function properly.

 

Let’s see an example.

The command “rpm -qR nano” is used in Linux-based operating systems to query the dependencies of the “nano” package.

# rpm -qR nano
/bin/sh
/bin/sh
/sbin/install-info
/sbin/install-info
config(nano) = 2.9.8-1.el8
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.27)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.6)(64bit)
libmagic.so.1()(64bit)
libncursesw.so.6()(64bit)
libtinfo.so.6()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1
rtld(GNU_HASH)

If the package is not installed, you will get output like this.

#rpm -qR nano
package nano is not installed

You can use the following command if the package is not installed.

rpm -qRp <rpm_package_file_path>

The “rpm -qRp” command is used in Linux systems to query the dependencies of an RPM package from an RPM package file without installing the package.

Here’s what each option does:

  • “-q”: This option stands for “query” and is used to query information about an RPM package.
  • “-R”: This option stands for “requires” and is used to display the dependencies required by an RPM package. It provides a list of other packages that need to be installed on the system for the specified RPM package to function properly.
  • “-p”: This option stands for “package” and is used to specify the RPM package file from which you want to query the dependencies. You need to provide the path to the RPM package file after this option.

 

When you run “rpm -qRp <rpm_package_file>”, where “<rpm_package_file>” is the path to the RPM package file you want to query.

The “rpm -qRp nano.rpm” command is used to query the list of packages that are provided as dependencies by an RPM package file named “nano.rpm” in a Linux-based operating system.

Check RPM package dependency with yum deplist command

“yum deplist” is a command used in Linux systems with yum package manager, which is used in Red Hat-based distributions such as CentOS, Fedora, and RHEL (Red Hat Enterprise Linux). It is used to list the dependencies of a specific package or packages.

The “deplist” option in “yum” stands for “dependency list”, and it allows you to view the dependencies of a package, including both the packages that are required (dependencies) and the packages that are optional (suggested or recommended dependencies) for the specified package.

Here’s how you can use the “yum deplist” command:

Syntax:

yum deplist <package_name>

Example:

yum deplist httpd

This command will display a list of packages that are required for the “httpd” package, which is the Apache HTTP Server package.

The “yum deplist” command can be useful for understanding the dependencies of a package, checking for missing dependencies, and troubleshooting issues related to dependencies when installing or updating packages using yum.

Check RPM package dependency with repoquery command

The “repoquery” command is used with various options to query different aspects of RPM packages. For example, you can use it to query the dependencies of a package with the “–requires” and “–resolve” options. You can also use “repoquery” to query other information such as file lists, package properties, and more.

Here’s an example of using “repoquery” to list the dependencies of the “nano” package.

Running “repoquery –requires –resolve nano” will generate a comprehensive list of all the packages that are required by “nano”, including the packages that are required by its dependencies, and so on.

This gives you a clear understanding of the complete list of packages that need to be installed for “nano” to function correctly on your system.

By using the “–requires” option, you’re instructing “repoquery” to list the direct dependencies of the “nano” package. But with the “–resolve” option, you’re taking it a step further. “repoquery” will not only provide the direct dependencies of “nano”, but also recursively resolve the dependencies of those dependencies, until all dependencies are listed.

# repoquery --requires --resolve nano
bash-0:4.4.20-4.el8_6.x86_64
file-libs-0:5.33-21.el8.x86_64
glibc-0:2.28-211.el8.i686
glibc-0:2.28-211.el8.x86_64
info-0:6.5-7.el8.x86_64
ncurses-libs-0:6.1-9.20180224.el8.x86_64

To install the “repoquery” command, you’ll need to have the appropriate package manager for your Linux distribution.

For RHEL (Red Hat Enterprise Linux):

sudo yum install yum-utils

Once the installation is complete, you’ll have access to the “repoquery” command in your Linux system.

Whether you’re troubleshooting package dependencies or managing software installations, the “repoquery” command with the “–requires” and “–resolve” options is a valuable tool to explore the intricate web of dependencies that a package like “nano” relies on.