CentOS

How to List Installed Packages on CentOS 7

Linux based operating systems such as CentOS have a modular packaging system. It helps reduce system file size and also makes package installation faster. CentOS is an RPM based distribution. The package files are distributed as an RPM archive. The RPM archives has the file extension .rpm. CentOS uses the YUM, an RPM package manager to install, remove and update packages. Recently newer version of Fedora started to use DNF package manager which one day may replace YUM.

As a Linux system administrator, it is a very common task to list all the installed packages of CentOS and other Linux based distributions. So in this article, I will show you how to list all the installed packages of CentOS 7. Let’s get started.

Listing Installed Packages on CentOS 7 with rpm Command:

You can use the rpm command to list all the installed packages on your CentOS 7 machine.

Run the following command to list all the installed packages on CentOS 7:

$ sudo rpm -qa

A long list of package that are installed on your CentOS 7 machine should be displayed.

Since the list is very long, you can pipe the output of the rpm command to less pager as follows:

$ sudo rpm -qa | less

Now you can press <Enter> to move forward one line at a time, or press <Space> to move forward several lines at a time. You can also press the <Up> and <Down> arrow keys to navigate through the list.

You can also search for packages here as well. Just press / and type in the search term (without space) you’re looking for. Once you’re done, press <Enter>. The lines containing the search term should be highlighted as you can see in the screenshot below. You can also press n and p to go to the next match and previous match respectively. Once you’re done, you can press q to exit out of the less pager.

Listing Installed Packages on CentOS 7 with YUM:

You can also list all the installed packages of your CentOS 7 machine with YUM package manager.

Run the following command to list all the installed packages of your CentOS 7 machine with yum:

$ sudo yum list installed

As you can see, the list of all the installed packages is displayed. It is a very long list.

Since the list is very long, you can also pipe the output of the yum command to the less pager as follows:

$ sudo yum list installed | less

As you can see, the output is opened with less pager. Now you can navigate the list using the <Up> and <Down> arrow keys or <Space> and <Enter> keys just like before. You can also search the list for certain term. I will show you a better way to search for installed packages with certain keyword later in this article.

Listing Installed Packages with repoquery:

repoquery is an interesting command. With repoquery you can do many things like search for a package that contains a certain file, see information about certain package, and of course list all the installed packages on CentOS 7.

repoquery is part of the yum-utils package which is not installed by default. You can install it with the following command:

$ sudo yum install yum-utils -y

You can list all the installed packages of your CentOS 7 machine with repoquery with the following command:

$ repoquery -a --installed

As you can see, all the installed packages are listed.

Checking for Specific Installed Packages on CentOS 7:

Now that you know how to list all the packages that are installed on your CentOS 7 machine, you can easily check whether a certain package is installed on your CentOS 7 machine.

One way is to search for the package with the less pager as shown earlier. The other way is to use grep or egrep, which is what I am going to show you in this section of the article.

For example, you can search for all the package name that has the keyword gnome in it with the following command:

$ sudo yum list installed | egrep -i gnome

NOTE: Here, the option -i is used for case insensitive search. By default, case sensitive search is performed. If you wish to perform case sensitive search, just remove the -i option.

As you can see, all the packages that has the keyword gnome is listed.

If you want to list all the package that starts with the keyword gnome, then run the following command:

$ sudo yum list installed | egrep -i '^gnome'

As you can see, all the package that starts with the keyword gnome is listed.

You can also list the packages that are not system dependent (noarch packages) with the following command:

$ sudo rpm -qa | egrep -i 'noarch$'

As you can see, all the packages that do not depend on the system architecture is listed.

So that’s how you list all the installed packages on CentOS 7. Thanks for reading this article.

About the author

Shahriar Shovon

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.