What files comprise an RPM package? Which package a file belongs to?

If you want to find the relationship between files on your system and RPM packages (which one owns/belongs-to which) then this page will be of help to you.

1. Contents of an RPM package

1.1.1. This RPM command will show you the contents of a package which is already installed on your system:

rpm -ql <package-name.rpm>

For example: rpm -ql skype will list all the files that the skype package installed onto your system. Note that you don’t need to give the exact name of the package (like skype- in my case). Of course giving the exact name of the package will also work (provided you type it correctly).

1.1.2 Here’s how to find the contents of an rpm package which is NOT yet installed (i.e. all the files inside the package, and where they will be installed):

rpm -qpl <path/to/file.rpm>

1.2. Which RPM package this file belongs to?

The below command will tell you what RPM package installed a given file onto your machine, i.e. what RPM package the file belongs to or which package “owns” the file (note that the file MUST be already installed for this to work):

rpm -qf /bin/bash

Try this on your system (must have bash :)) and you should see the rpm command output the name of the bash package, something like bash-3.2-23.fc9.i386

3 thoughts on “What files comprise an RPM package? Which package a file belongs to?

  1. Often a poorly packaged app would miss a dependency – usually an shared object library (a .so file). In such cases you’d see an error like:
    /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

    So in this case it would be nice to find out which packages provides the ld-linux.so.2 file.

    $ yum whatprovides ld-linux.so.2
    glibc-2.14.90-14.i686 : The GNU libc libraries
    Repo : fedora
    Matched from:
    Other : ld-linux.so.2

    This tells us that the ld-linux so lib is provided by the glibc library. Note that you must give the exact so name to yum whatprovides, whereas when installing you may just type yum install glibc and it will find the correct version.
    (Note: yum is Fedora’s package manager / frontend to the rpm command)

  2. This is how you can list all the packages installed on your system:
    yum list installed

    The resulting list of packages will be quite long so if you have an idea what you’re looking for (e.g. if you looking for all the “ncurses” packages) you may do something like:
    yum list installed | grep ncurses

  3. And using dnf:

     $ dnf provides pkg-config
    Last metadata expiration check: 0:07:13 ago on Wed 14 Feb 2018 02:20:06 PM EET.
    pkgconf-pkg-config-1.3.7-1.fc26.x86_64 : pkgconf shim to provide /usr/bin/pkg-config
    Repo        : @System
    pkgconf-pkg-config-1.3.12-2.fc26.i686 : pkgconf shim to provide /usr/bin/pkg-config
    Repo        : updates

    As you can see, in this case the pkg-config command is provided by both the @System and Updates repos.

    – – – – –

    Another similar and VERY useful command would be:

     $ dnf --showduplicates list firefox

    This will show you which version of the package (firefox in this example) is installed on your computer, if any, and which versions (higher AND lower) are available.

    This way, if you need to, you could downgrade a package! In this particular case this is what the command output for me:

    Last metadata expiration check: 0:10:59 ago on Wed 14 Feb 2018 02:20:06 PM EET.
    Installed Packages
    firefox.x86_64                              56.0-5.fc26                                 @updates
    Available Packages
    firefox.x86_64                              54.0-2.fc26                                 fedora  
    firefox.x86_64                              56.0-5.fc26                                 @updates
    firefox.x86_64                              58.0.1-1.fc26                               updates

Leave a Reply

Your email address will not be published. Required fields are marked *