How to List Installed Packages on CentOS

Updated 

3 min read

In this tutorial, we will show you how to list and filter installed packages on CentOS. Knowing how to list installed packages on your CentOS system can be helpful in situations where you need to install the same packages on another machine or if you want to re-install your system.

We will also show you how to check whether a specific package is installed, count installed packages, and find out the version of an installed package.

List Installed Packages with Yum

YUM(Yellow dog Updater,) is the default CentOS package manager. It can be used to download, install, remove, query, and managing CentOS RPM software packages from the official and third-party CentOS repositories.

To list the installed packages on your CentOS system with yum, use the following command:

sudo yum list installed

It will print a list of all installed packages, including information about the versions and repository of the RPM packages.

Usually, the packages list is long, for better readability it is a good idea to pipe the output to less:

sudo yum list installed | less

To find out whether a specific package is installed, filter the output with the grep command.

For example, to find out if the unzip package is installed on the system you would run:

sudo yum list installed | grep unzip
unzip.x86_64    6.0-19.el7    @anaconda

The output above shows that unzip version 6.0-19 is installed on the machine.

List Installed Packages with Rpm

The rpm command with the -q option allows you to query the packages.

The following command will list of all installed packages:

sudo rpm -qa

To query (search) whether a certain package is installed pass the package name to the rpm -q command. The following command will show you whether the tmux package is installed on the system:

sudo rpm -q tmux

If the package is installed, you will see something like this:

tmux-1.8-4.el7.x86_64

Otherwise, the command will print:

package tmux2is not installed

To get more information about the queried package pass -i:

sudo rpm -qi tmux

Create a List of all Installed packages

To create a list of the names of all installed packages on your CentOS system and save it in a file named packages_list.txt, redirect the command output to the file:

sudo rpm -qa > packages_list.txt

To install the same packages on another server you can use the cat command to pass all packages to yum:

sudo yum -y install $(cat packages_list.txt)

Count the number of installed packages

To find out how many packages are installed on your system, use the same command as before but instead of redirecting the output to a file, pipe it to the wc utility to count the lines:

sudo rpm -qa | wc -l
603

The output above shows that there are 603 packages installed.

Conclusion

In CentOS systems you can list installed packages using the yum list installed and rpm -qa commands.

Feel free to leave a comment if you have any questions.