How to list all files contained in an RPM package

Last updated on July 10, 2020 by Dan Nanni

Suppose you want to install a particular RPM package on Fedora or CentOS, but want to check the content of the package before installing it. This situation may arise when you try to install any missing binary or library file in your system.

In this tutorial, I will describe how to list all files contained in a RPM package on CentOS, Fedora or RHEL.

Method One: repoquery

There is a command-line tool called repoquery which can query information of YUM repositories. This tool allows you to view the content of a RPM package without installing the package.

To install repoquery on CentOS, Fedora or RHEL:

$ sudo yum install yum-utils

To check a list of files contained in a particular package (e.g., tcpdump) using repoquery:

$ repoquery -l tcpdump
/usr/sbin/tcpdump
/usr/sbin/tcpslice
/usr/share/doc/tcpdump-4.3.0
/usr/share/doc/tcpdump-4.3.0/CHANGES
/usr/share/doc/tcpdump-4.3.0/CREDITS
/usr/share/doc/tcpdump-4.3.0/LICENSE
/usr/share/doc/tcpdump-4.3.0/README
/usr/share/man/man8/tcpdump.8.gz
/usr/share/man/man8/tcpslice.8.gz

Method Two: rpm

The second method to view all the files inside a package without installing it is via rpm command. In this case, however, you need to download a RPM package locally in order to query the package with rpm command.

You can download a RPM package with yum command. Since you do not want to install it, you must use --downloadonly option.

To download a particular RPM package without installing it, you need to install a Yum plugin for adding --downloadonly command option as follows.

$ sudo yum install yum-plugin-downloadonly

Now you can use yum command to download an RPM package as follows.

$ sudo yum reinstall tcpdump -y --downloadonly --downloaddir=/tmp

With reinstall option, the above command will download a requested RPM package, even when the package is currently installed on your system. The downloaded package will be stored in /tmp directory as requested.

To list files of a downloaded RPM package, run the following command.

$ rpm -qpl /tmp/tcpdump-4.3.0-2.fc18.x86_64.rpm 

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean