Useful RPM and YUM Commands

RPM and YUM commands are used daily by RHEL/CentOS/Fedora Administrators and sometimes having a few more tricks up you sleeve for getting information from the command line are always handy to have.  Listed in this post are 14 useful commands for RPM and YUM.

1. Getting rpm to display architecture

This one is a pretty simple tip, and very useful especially for people using x86_64 systems. Just one line in ~/.rpmmacros will save all sorts of trouble later.

2. Query packages not from Redhat

Want to query all those packages installed from 3rd party repositories, not Redhat?

3. Reset File Permissions

Have you managed to completely mess up file permissions for a given package? Not a problem, because RPM has you covered.

4. View the Changelog

Because Redhat and the upstream vendor have backported security patches, the version numbers can often be misleading when you look for CVE fixes. Checking the changelog of a package is a good way to see if the fix has been implemented. Once again, rpm comes to the rescue.

5. Where’s the Documentation?

To quickly list documentation relating to a package, you can use the following two options:

This will show you the documentation contained in that rpm, or if you only have a filename you can do:

and rpm will show you the documentation in the package that owns the file.

6. Package Origin

Occasionally it’s nice to know where you got certain packages, or how many packages you have on your system from a particular repository or vendor. There are a couple of search options that you can use which are not in the rpm man pages to help you out here. While they’re not 100% perfect, they certainly help out. Most package repositories tag their packages with an identifier in the Release string. For example rpmforge uses rf as their identifier. You can use this to see what you have of theirs installed with

or if you want to see just how many packages you have installed built by Fred you could use

This trick works for most categories visible in rpm -qi <packagename>.

Another approach is to use the keychecker package available in the EPEL repository, which lists rpm packages based on the GPG key they were signed with.

7. Extract just one File

If you need to extract just one file from an rpm without reinstalling the whole package, you can do this with rpm2cpio. For example, to extract just the config file from the logrotate rpm you would use the following statement:

8. Query Package Install Order and Dates

Useful after an upgrade to find old packages that were not upgraded.

Review the end of the output file in “less” to find all RPMS older than the install date. Can also grep for specific packages and see when they were installed.

9. Query Available Packages from a Repo

Find all packages available from a specific repository, e.g. RPMfusion. This does not show the already installed packages from this repository.

10. Search yum repositories for a string

Find packages containing a string in package name or description.

11. Using yum with a proxy server

To enable yum operations to use a proxy server you should first add the following parameter to /etc/yum.conf

where yourproxy is the name of the proxy server you want to access and 8080 is the proxy port. If the server requires authentication you can specify the login credentials like:

The rpm package manager makes use of the proxy environment variable. This can be set system wide in /etc/profile or user specific in ~/.bash_profile::

To use wget through a proxy server add the following lines to /etc/wgetrc

In both cases, login information can be set like in the example above.

12. Use yum to install a local package, automatically checking/satisfying dependencies

13. Display priority scores for all repositories

You can list all repositories set up on your system by a yum repolist all. However, this does not show priority scores. Here’s a one liner for that. If no number is defined, the default is the lowest priority (99).

14. Show all installed GPG keys

Shows all GPG keys along with the corresponding repo information.


Hope this has added a few more ticks up your sleeve as it has mine!

Leave a Reply

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