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.
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.
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.
Similar to rpm, the yum package manager also allows you to get a list of installed packages.
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.
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.
To list all installed packages:
To list all installed packages from EPEL repository:
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:
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.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!