yum Command: List The Contents (Files) Of A Package on Linux

The rpm -qi command list the files of a package. How do I use yum command to list the contents of a package under a CentOS or RHEL installed on IBM server hardware? How to list the contents of a package using yum command?

Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements yum command
RHEL/SL/CentOS
Time N/A
You can not use yum command for rpm queries. You need to use the repoquery command for querying information from yum repositories similarly to rpm queries. This command will work with installed packages as well packages currently not installed on the Linux based system.

ADVERTISEMENTS

How to list the contents of a package using yum command

The procedure to list the files installed by a yum package:

  1. Open the terminal bash shell and type:
    sudo yum install yum-utils
  2. See the files installed by a yum package named bash:
    repoquery --list bash
    repoquery -l '*bash*'

Let us see installation and usage in details.

Installation

First you need to install yum-utils package. It is a collection of utilities and examples for the yum package manager. It includes utilities by different authors that make yum easier and more powerful to use. Type the following yum command to install yum-utils package:
# yum -y install yum-utils
Sample outputs:

Loaded plugins: product-id, protectbase, rhnplugin, security, subscription-
              : manager
Updating certificate-based repositories.
Unable to read consumer identity
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.30-14.el6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package        Arch        Version             Repository                 Size
================================================================================
Installing:
 yum-utils      noarch      1.1.30-14.el6       rhel-x86_64-server-6      101 k
 
Transaction Summary
================================================================================
Install       1 Package(s)
 
Total download size: 101 k
Installed size: 0  
Downloading Packages:
yum-utils-1.1.30-14.el6.noarch.rpm                       | 101 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : yum-utils-1.1.30-14.el6.noarch                               1/1 
Installed products updated.
  Verifying  : yum-utils-1.1.30-14.el6.noarch                               1/1 
 
Installed:
  yum-utils.noarch 0:1.1.30-14.el6                                              
 
Complete!

Syntax

The syntax is:

repoquery -l {package-name-here}
repoquery -q -l {package-name-here}
repoquery -q -l --plugins {package-name-here}
repoquery -q -l --plugins *{package-name-here}*

Where,

  • -l : List files in package
  • -q : For rpmquery compatibility (not needed)
  • --plugins : Enable plug-ins support

Examples

To list the contents of a package called htop using yum, run:
repoquery -q -l --plugins htop
Sample outputs:
How to list the contents of a package using yum command on Linux
Equivalent rpm command syntax:
# rpm -ql {packageName}
# rpm -ql htop
# rpm -qlp /path/to/nginx.rpm

To list and match all php packages, enter:
repoquery -q -l --plugins php*
OR (warning may take a long time)
repoquery -q -l --plugins php* | less

A note about Fedora Linux users and dnf command

Fedora latest comes with dnf command. So the syntax is as follows:
# dnf repoquery -l {packageName}
# dnf repoquery -l htop

How to show general information about package

Pass the -i option to the repoquery command:
# repoquery -i {packageNamehere}
# repoquery -i nginx

Sample outputs:

Name        : nginx
Version     : 1.13.8
Release     : 1.el7_4.ngx
Architecture: x86_64
Size        : 2665830
Packager    : None
Group       : System Environment/Daemons
URL         : http://nginx.org/
Repository  : nginx
Summary     : High performance web server
Source      : nginx-1.13.8-1.el7_4.ngx.src.rpm
Description :
nginx [engine x] is an HTTP and reverse proxy server, as well as
a mail proxy server.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 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 VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • Leslie Satenstein Dec 16, 2012 @ 16:51

    Your emails with wonderful reminders or tutorials of explanation, are much appreciated.
    I have your emails archived with thunderbird and my gmail account.

  • Spencer Williams Jun 25, 2014 @ 15:14

    Hey, thanks a lot for this! But say, I don’t think the -q option is necessary, given this description for it in repoquery’s man page:

    -q, –query
    For rpmquery compatibility, doesn’t do anything.

Leave a Reply

Your email address will not be published.

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