How to list all installed packages on CentOS or RHEL

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

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

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

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

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

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Ask Xmodulo

Do you want to receive Linux related questions & answers published at Ask Xmodulo? Enter your email address below, and we will deliver our Linux Q&A straight to your email box, for free. Delivery powered by Google Feedburner.


Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

Leave a comment

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