Read in 3 minutes
How to List Installed Packages on CentOS
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 you can use the following command:
sudo yum list installed
It will print a list of all installed packages including information about the packages versions and repository.
The packages list is long, for better readability it is a good idea to pipe the output to
sudo yum list installed | less
To find out whether a specific package is installed you can filter the output with the grep command.
For example, to find out if the unzip package is installed on our system we will run:
sudo yum list installed | grep unzip
unzip.x86_64 6.0-19.el7 @anaconda
The output above shows that we have unzip version 6.0-19 installed on our machine.
List Installed Packages with Rpm
In CentOS, you can use the
rpm command with the
-q option to query the packages. The following command will list of all installed packages:
sudo rpm -qa
rpm will show you only the packages names.
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
Id the package is installed you will see something like this:
Otherwise, the command will print:
package tmux2is not installed
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, run the following command:
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
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 you can use the same command as before but instead of redirecting the output to a file you can pipe it to the
wc utility and count the lines:
sudo rpm -qa | wc -l
The output above shows that there are 603 packages installed in the system.
By now you should know how to list and filter installed packages on your CentOS system. There is also another tool named
repoquery that is included in the
yum-utils package which you can use to get a list of the installed packages.
Feel free to leave a comment if you have any questions.