linuxfedorarpmyumpackage-managers

How can I list the contents of a package using YUM?


I know how to use rpm to list the contents of a package (rpm -qpil package.rpm). However, this requires knowing the location of the .rpm file on the filesystem.

A more elegant solution would be to use the package manager, which in my case is YUM. How can YUM be used to achieve this?


Solution

  • There is a package called yum-utils that builds on YUM and contains a tool called repoquery that can do this.

    repoquery --help | grep -E "list\ files"
    

    Output:

    -l, --list            list files in this package/group
    

    Combined into one example:

    repoquery -l time
    

    Output:

    /usr/bin/time
    /usr/share/doc/time-1.7
    /usr/share/doc/time-1.7/COPYING
    /usr/share/doc/time-1.7/NEWS
    /usr/share/doc/time-1.7/README
    /usr/share/info/time.info.gz
    

    On at least one Red Hat Linux system, with rpm v4.8.0, YUM v3.2.29, and repoquery v0.0.11, repoquery -l rpm prints nothing.

    If you are having this issue, try adding the --installed flag: repoquery --installed -l rpm.


    DNF Update:

    To use DNF instead of yum-utils, use the following command:

    dnf repoquery -l time
    

    Output:

    /usr/bin/time
    /usr/share/doc/time-1.7
    /usr/share/doc/time-1.7/COPYING
    /usr/share/doc/time-1.7/NEWS
    /usr/share/doc/time-1.7/README
    /usr/share/info/time.info.gz