In this guide, I will show you how you can filter and list installed packages on CentOS. Whenever you install any packages on CentOS, it is advisable to know how to show installed packages. After checking out the same packages installed, you can decide whether or not to install older packages.
In this article, you will learn how to check which packages are installed, find out versions of installed packages and count installed packages on CentOS systems.
Table of Contents
List Installed Packages with Yum on CentOS
In the CentOS, the package manager is identified as YUM (Yellow Dog Updater). Before typing any command in CentOS, you have to prefix it with YUM. The YUM package manager can be used to install, remove, download and update CentOS RPM software packages directly from official repositories as well as third-party repositories.
To list out the installed packages on the CentOS system using yum, you can use the following command.
sudo yum list installed
Here, we are using sudo to run the command as a root user privileges. The above command will output the list of all installed RPM packages of CentOS as well as information about the versions. Have a look at the screenshot below.
Normally, there are many default packages are available on the CentOS system. However, you can use less to display the readable output of the package list using the below command.
sudo yum list installed | less
To find out any specific packages on the system, you must filter the output using the grep command.
Let’s assume, we have to find out whether the unzip package is installed or not. In this case, we will use the following command.
sudo yum list installed | grep unzip
The output will be displayed as below.
You can see in the above output, the unzip version 6.0-19 is installed on the system.
List installed packages with RPM
The rpm command allows you to query the packages and list out the installed packages. To query the packages use -q option with rpm command.
sudo rpm -qa
To search whether or not certain packages installed on the system, simply write the package name with rpm -q command. See the command below to check tmux package is installed on CentOS or not.
sudo rpm -q tmux
If the tmux package is installed, then you will see an output as below.
If the package is not installed, it will output like…
package tmux2is not installed
Next, to get more information about the tmux package, type command as below.
sudo rpm -qi tmux
Create a list of all installed packages
There is a way to create a list of all installed packages on CentOS and then save it in text file separately. You just have to redirect the output of the command to the file using > operator.
sudo rpm -qa > packages_list.txt
To install the packages on the server you can use the cat command to pass the details to yum.
sudo yum -y install $(cat packages_list.txt)
Count the number of installed packages
You can easily find out how many packages are installed on the system. To do that, we have to pie the command output to wc utility to count the lines.
sudo rpm -qa | wc -l
It will return the count of a number of the packages installed on the system.
In the CentOS systems, It is an easy process to list installed packages using the yum list installed command. Alternatively, the rpm -qa command is useful in counting the list of all packages and return the integer number.