How to list all installed packages on CentOS or RHEL

Last updated on October 21, 2020 by Dan Nanni

Question: I want to find out what packages are installed on my CentOS box, so that I can replicate all the installations on another computer. Is there a way to get a full list of all RPM packages that I installed since I set up my initial CentOS system?

When you want to create a new server which has exactly the same set up as any existing server X, you need to find out what packages have been installed on server X. Also when you are trying to migrate your old Linux system to to a freshly installed newer OS release, you need to keep track of previously installed package list. In other times, you may just want to know what packages you installed from a specific third-party repository.

If you are running CentOS or RHEL system, there are a few ways to get a list of all installed RPM packages, either from all available repositories or from a specific repository.

Method One: rpm

The easiest way to show all installed packages on CentOS is via rpm command. The following command queries all installed packages and shows the result.

$ rpm -qa

However, the rpm command itself does not recognize the notion of repositories. So if you want to get a list of packages installed from a particular repository, rpm cannot help you.

Method Two: yum

Similar to rpm, the yum package manager also allows you to get a list of installed packages.

$ yum list installed

Since the yum output contains repository information, if you want to get a list of RPM packages installed from a specific repository only, you can filter the output with grep. The following command shows a list of packages installed from EPEL repository.

$ yum list installed | grep @epel

Method Three: repoquery

Another tool for querying information about RPM packages and yum repositories is repoquery. This tool is useful to inspect package dependencies, search files inside a package, as well as packages from different repositories. You can fully customize and format its output, so it can be fed to other tools easily.

repoquery is part of yum-utils package, so you need to install it first.

$ sudo yum install yum-utils

To list all installed packages:

$ repoquery -a --installed

To list all installed packages from EPEL repository:

$ repoquery -a --installed --qf "%{name} %{ui_from_repo}" | grep @epel

Method Four: yumdb

If you are interested in a specific repository only, another useful tool is the yumdb command. This utility queries the local yum database to find information about installed packages. The yum database is a flat file key-value store generated by the yum command to store any package-specific information.

To see all the packages installed from EPEL repository:

$ yumdb search from_repo epel

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean