Jan 10, 2023 2 min read

List Installed Packages on CentOS

You will check if a certain package is installed, count the number of installed packages, and determine the version of an installed package in this tutorial.

List Installed Packages on CentOS
Table of Contents

Introduction

When you need to install the same packages on a different machine or need to reinstall your CentOS system, it might be helpful to know how to list the packages that are installed on your system.

In this tutorial, you will check if a certain package is installed, count the number of installed packages, and determine the version of an installed package.

List Installed Packages with Yum

The default package manager for CentOS is YUM (Yellow Dog Updater). It can be used to download, install, delete, query, and manage RPM software packages from official CentOS repositories as well as third-party sources.

Use the following command to list the packages that are installed on your CentOS system with yum:

sudo yum list installed

A list of all installed packages, along with details about their versions and the repository of the RPM packages, will be printed by the program.

Since the packages list is usually lengthy, so it is advisable to pipe the output to less:

sudo yum list installed | less

Use the grep command to filter the output and check if a given package is installed.

For instance, you might execute the following command to see if the unzip package is installed on the system:

sudo yum list installed | grep unzip
Output

unzip.x86_64    6.0-19.el7    @anaconda

The output above indicates that the system has unzipped version 6.0-19 installed.

List Installed Packages with Rpm

You can query the packages using the rpm command's -q option.

All installed packages will be listed using the following command:

sudo rpm -qa

Pass the package name to the rpm -q command to see if a specific package has been installed. You may check to see if the tmux package is installed on the system by running the command below:

sudo rpm -q tmux

You will see something similar to this if the package has been installed:

Output

tmux-1.8-4.el7.x86_64

If not, the command will print:

Output

package tmux2is not installed

To learn more about the package being queried, pass -i:

sudo rpm -qi tmux

Create a List of all Installed packages

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

sudo rpm -qa > packages_list.txt

You can use the cat command to pass all packages to yum in order to install the same packages on another server:

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

Count the number of installed packages

To determine the number of packages installed on your system, use the same command as earlier, but instead of redirecting the output to a file, pipe it to the wc utility to count the lines:

sudo rpm -qa | wc -l
Output

603

The output above indicates that 603 packages are installed.

Conclusion

You can use the yum list installed and rpm -qa commands to list installed packages in CentOS systems.

If you have any queries, feel free to leave a comment below, and we'll be happy to help.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.