What Files Are In a RPM Package?

How do I find out what files are in RPM package called gnupg using command line option? How do I list the contents of a package using rpm or yum command on CentOS/RHEL/Fedora/Red Hat/OpenSuse/Novell Suse Linux?

You can use rpm command (rpm command) itself to list the files inside a RPM package. rpm is a powerful Package Manager, which can be used to build, install, query, verify, update, and erase individual software packages. A package consists of an archive of files and meta-data used to install and erase the archive files.
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
RequirementsNone
Time1m

ADVERTISEMENTS

rpm: Find out what files are in my rpm package

Use following syntax to list the files for already INSTALLED package:
rpm -ql package-name

Use following syntax to list the files for RPM package:
rpm -qlp package.rpm

Type the following command to list the files for gnupg*.rpm package file:
$ rpm -qlp rpm -qlp gnupg-1.4.5-1.i386.rpm
Sample outputs:

/usr/bin/gpg
/usr/bin/gpgsplit
/usr/bin/gpgv
/usr/bin/lspgpot
/usr/lib64/gnupg
/usr/lib64/gnupg/gpgkeys_ldap
/usr/lib64/gnupg/gpgkeys_mailto
/usr/share/doc/gnupg-1.2.6
/usr/share/doc/gnupg-1.2.6/AUTHORS
/usr/share/doc/gnupg-1.2.6/BUGS
/usr/share/doc/gnupg-1.2.6/COPYING
/usr/share/doc/gnupg-1.2.6/ChangeLog
/usr/share/doc/gnupg-1.2.6/DETAILS
/usr/share/doc/gnupg-1.2.6/HACKING
/usr/share/doc/gnupg-1.2.6/INSTALL
/usr/share/doc/gnupg-1.2.6/NEWS
....
..
...

In this example, list files in a installed package called ksh:
$ rpm -ql ksh
Sample outputs:

/bin/ksh
/bin/ksh93
/etc/kshrc
/etc/skel/.kshrc
/usr/share/doc/ksh-20120801
/usr/share/doc/ksh-20120801/COMPATIBILITY
/usr/share/doc/ksh-20120801/ChangeLog
/usr/share/doc/ksh-20120801/README
/usr/share/doc/ksh-20120801/RELEASE
/usr/share/man/man1/ksh.1.gz
/usr/share/man/man1/ksh93.1.gz

List the contents of a package using yum command

You need to install yum-utils package and use a command called repoquery to list the contents of a rpm package file:
$ repoquery -q -l --plugins ksh

/bin/ksh
/bin/ksh93
/etc/kshrc
/etc/skel/.kshrc
/usr/share/doc/ksh-20120801
/usr/share/doc/ksh-20120801/COMPATIBILITY
/usr/share/doc/ksh-20120801/ChangeLog
/usr/share/doc/ksh-20120801/README
/usr/share/doc/ksh-20120801/RELEASE
/usr/share/man/man1/ksh.1.gz
/usr/share/man/man1/ksh93.1.gz
See also
  1. HowTo: Extract an RPM Package Files Without Installing It
  2. rpm command cheat sheet
  3. Man pages: repoquery(1)
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
7 comments… add one
  • Obaid H. Mnee Aug 27, 2009 @ 7:46

    dear Sir,
    I have some problems while installing the oracle on linux Enterprse 5
    I hope you can help me with a list of needed RPM files to pass this probmes

    regards,
    Husam

  • Simon Smith Jan 5, 2010 @ 15:41

    Thanks Vivek, great writeup, saved me from staring at the man page.

  • ala2200 Oct 26, 2011 @ 9:34

    If you want explicit output (owner, permision, etc) you can use:
    > rpm2cpio | cpio -tv

    • Ashok Apr 23, 2012 @ 4:10

      Good one ‘ala2200’

  • dixit Nov 4, 2011 @ 7:28

    Thanks Vivek, great writeup, saved me from staring at the man page.

  • David May 27, 2015 @ 22:34

    I take it, this:

    $ rpm -qlp rpm -qlp gnupg-1.4.5-1.i386.rpm

    should be this:

    $ rpm -qlp gnupg-1.4.5-1.i386.rpm

    Yes?

  • Tom Ritsema Nov 3, 2016 @ 14:04

    Yes, that’s correct, it should be
    $ rpm -qlp gnupg-1.4.5-1.i386.rpm

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.