How to check and list installed packages in CentOS Linux

How do I check installed packages in CentOS Linux version 6.x/7.x/8.x? How can I List installed packages on CentOS Enterprise Linux server?

This page shows you how to check and list all installed packages in CentOS Linux server version 6.x/7.x/8.x using various command-line utilities. Such a list is useful in case if you need to restore/reinstall or mirror the same packages across different CentOS servers.

How to check installed packages in CentOS

The procedure is as follows to list installed packages:

  1. Open the terminal app.
  2. For remote server log in using the ssh command: ssh user@centos-linux-server-IP-here
  3. Show information about all installed packages on CentOS, run: sudo yum list installed
  4. To count all installed packages run: sudo yum list installed | wc -l
  5. Want to save all installed packages names in a file? Try: sudo yum list installed > my_list.txt
  6. Execute the command sudo yum update to refresh package database and install updates if any.

Let us see all commands and examples in details.

Check and list installed packages with yum command

From the dnf/yum man page:

The list command dumps lists of packages depending on the packages’ relation to the system. A package is installed if it is present in the RPMDB, and it is available if it is not installed but it is present in a repository that DNF knows about. The list command can also limit the displayed packages according to other criteria, e.g. to only those that update an installed package. The exclude option in configuration file (.conf) might influence the result, but if the command line option –disableexcludes is used, it ensure that all installed packages will be listed.

Hence, to lists installed packages on CentOS, type the following yum command:
sudo yum list --installed
sudo yum list --installed | more

Check installed packages in centos linux

List all installed packages in CentOS Linux using yum

One can use the grep command as filter too. For example, find out if nginx installed or not:
sudo yum list --installed | grep nginx
Want to lists extras packages installed on the system that are not available in any known repository? Try:
sudo yum list --extras
Sample outputs

Last metadata expiration check: 0:21:58 ago on Friday 29 November 2019 05:19:57 PM UTC.
Extra Packages
qemu-guest-agent.x86_64            15:2.12.0-64.module_el8.0.0+44+94c1b039.2             @AppStream

Lists all packages known to us:
sudo yum list --all
Finally, show available packages, run:
sudo yum list --available
One can count all installed packages using the wc command:
sudo yum list --installed | wc -l
sudo yum list --all | wc -l
sudo yum list --available | wc -l

Display packages list that needs updates/patching

Keeping your CentOS box secure is an essential task. One can get a list of all upgrades available for the installed packages too. Type:
sudo yum list --upgrades
sudo yum list --upgrades | more
sudo yum list --upgrades | grep -i kernel

Sample outputs:

Available Upgrades
bash.x86_64                             4.4.19-8.el8_0                                    BaseOS   
dracut.x86_64                           049-10.git20190115.el8_0.1                        BaseOS   
dracut-config-rescue.x86_64             049-10.git20190115.el8_0.1                        BaseOS   
dracut-network.x86_64                   049-10.git20190115.el8_0.1                        BaseOS   
dracut-squash.x86_64                    049-10.git20190115.el8_0.1                        BaseOS   
grub2-common.noarch                     1:2.02-66.el8_0.1                                 BaseOS   
grub2-pc.x86_64                         1:2.02-66.el8_0.1                                 BaseOS   
grub2-pc-modules.noarch                 1:2.02-66.el8_0.1                                 BaseOS   
grub2-tools.x86_64                      1:2.02-66.el8_0.1                                 BaseOS   
grub2-tools-extra.x86_64                1:2.02-66.el8_0.1                                 BaseOS   
grub2-tools-minimal.x86_64              1:2.02-66.el8_0.1                                 BaseOS   
initscripts.x86_64                      10.00.1-1.el8_0.1                                 BaseOS   
kernel.x86_64                           4.18.0-80.11.2.el8_0                              BaseOS   
kernel-core.x86_64                      4.18.0-80.11.2.el8_0                              BaseOS   
kernel-modules.x86_64                   4.18.0-80.11.2.el8_0                              BaseOS   
kernel-tools.x86_64                     4.18.0-80.11.2.el8_0                              BaseOS   
kernel-tools-libs.x86_64                4.18.0-80.11.2.el8_0                              BaseOS   
kpartx.x86_64                           0.7.8-7.el8_0.2                                   BaseOS   
libnfsidmap.x86_64                      1:2.3.3-14.el8_0.2                                BaseOS   
platform-python.x86_64                  3.6.8-4.el8_0                                     BaseOS   
python3-libs.x86_64                     3.6.8-4.el8_0                                     BaseOS   
python3-perf.x86_64                     4.18.0-80.11.2.el8_0                              BaseOS   
python3-rpm.x86_64                      4.14.2-11.el8_0                                   BaseOS

Get a list of all installed packages with rpm command

Simply run the following rpm command:
sudo rpm -qa
sudo rpm -qa | more
sudo rpm -qa | wc -l
sudo rpm -qa | grep bash

How to List Installed Packages on CentOS

Use rpm command to display a list of install installed packages on CentOS server

Is nginx and bash package installed? Find out, run:
sudo rpm -q nginx
package nginx is not installed
sudo rpm -q bash

Use repoquery command from dnf-utils package

First, install yum-utils (CentOS 6.x/7.x) or dnf-utils on a CentOS 8.x:
sudo yum install yum-utils ## centos 6.x/7.x ##
sudo yum install dnf-utils ## centos 8.x ##

Sample outputs:

Last metadata expiration check: 0:40:40 ago on Friday 29 November 2019 05:19:57 PM UTC.
Dependencies resolved.
 Package                Arch                Version                      Repository           Size
 dnf-utils              noarch                    BaseOS               62 k
Transaction Summary
Install  1 Package
Total download size: 62 k
Installed size: 18 k
Is this ok [y/N]: y
Downloading Packages:
dnf-utils-                                  11 MB/s |  62 kB     00:00    
Total                                                              6.1 MB/s |  62 kB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                           1/1 
  Installing       : dnf-utils-                                            1/1 
  Running scriptlet: dnf-utils-                                            1/1 
  Verifying        : dnf-utils-                                            1/1 

To check installed packages in CentOS Linux, execute:
sudo yum repoquery -a --installed


Display name, architecture and the containing repository of all nginx packages:
sudo yum repoquery --queryformat '%{name}.%{arch} : %{reponame}' nginx
List all available packages providing “webserver”:
sudo yum repoquery --whatprovides webserver
Or list all available packages providing “webserver” but only for “i686” architecture:
sudo yum repoquery --whatprovides webserver --arch i686

More on repoquery option

Custom display format created using the -qf %{format} or --queryformat %{format} syntax. The %{format} is nothing but a string to output for each matched package. Every occurrence of %{<tag>} within is replaced by corresponding attribute of the package. List of recognized tags can be displayed by running
dnf repoquery --querytags
Sample outputs:

Available query-tags: use --queryformat ".. %{tag} .."

name, arch, epoch, version, release, reponame (repoid), evr,
debug_name, source_name, source_debug_name,
installtime, buildtime, size, downloadsize, installsize,
provides, requires, obsoletes, conflicts, sourcerpm,
description, summary, license, url

For instance, one can build fancy list as follows:
repoquery -a --installed \
--queryformat "%{name}-%{arch}-%{version} installed at '%{installtime}' from '%{reponame}'"

Sample outputs:

newt-x86_64-0.52.20 installed at '2019-09-25 14:48' from '@System'
nftables-x86_64-0.9.0 installed at '2019-09-25 14:48' from '@System'
npth-x86_64-1.5 installed at '2019-09-25 14:48' from '@System'
numactl-libs-x86_64-2.0.12 installed at '2019-09-25 14:48' from '@System'
openldap-x86_64-2.4.46 installed at '2019-09-25 14:48' from '@System'
openssh-clients-x86_64-7.8p1 installed at '2019-09-25 14:49' from '@System'
openssh-server-x86_64-7.8p1 installed at '2019-09-25 14:49' from '@System'
openssh-x86_64-7.8p1 installed at '2019-09-25 14:49' from '@System'
openssl-libs-x86_64-1.1.1 installed at '2019-09-25 14:48' from '@System'
openssl-pkcs11-x86_64-0.4.8 installed at '2019-09-25 14:48' from '@System'
openssl-x86_64-1.1.1 installed at '2019-09-25 14:48' from '@System'
os-prober-x86_64-1.74 installed at '2019-09-25 14:48' from '@System'
p11-kit-trust-x86_64-0.23.14 installed at '2019-09-25 14:48' from '@System'
p11-kit-x86_64-0.23.14 installed at '2019-09-25 14:48' from '@System'
pam-x86_64-1.3.1 installed at '2019-09-25 14:48' from '@System'
parted-x86_64-3.2 installed at '2019-09-25 14:49' from '@System'
passwd-x86_64-0.80 installed at '2019-09-25 14:49' from '@System'

How to check for installed packages on CentOS and backup them

One can list and backup all installed packages using the following syntax:

rpm -qa --qf "%{NAME}\n" |\
sort > /nas/installed-software-mm-dd-yyyy.log

Use the cat command to review list:
cat /nas/installed-software-mm-dd-yyyy.log
To restore all those packages when needed, run:
yum -y install $(cat /nas/installed-software-mm-dd-yyyy.log)
See “Linux Get List of Installed Software for Reinstallation / Restore All the Software Programs” for more info.

A note about listing all installed packages with yum on CentOS history command

The yum command has history option on the latest version of CentOS / RHEL v6.x+. One can view historical installation date and data on your cloud based server. Type the following command to see a list and history:
sudo yum history
Sample outputs:

ID     | Command line             | Date and time    | Action(s)      | Altered
     4 | install dnf-utils        | 2019-11-29 18:00 | Install        |    1   
     3 | remove dnf-utils         | 2019-11-29 18:00 | Removed        |    1   
     2 | install yum-utils        | 2019-11-29 17:21 | Install        |    1   
     1 |                          | 2019-09-25 14:48 | Install        |  396 EE

We can examine history entries in detail too using ID number from the above outputs:
sudo yum history info ID
sudo yum history info 2

Sample outputs:

Transaction ID : 2
Begin time     : Friday 29 November 2019 05:21:50 PM UTC
Begin rpmdb    : 393:911fb7e090842db316c671dc9e4b3bba7ffc7f2d
End time       : Friday 29 November 2019 05:21:50 PM UTC (0 seconds)
End rpmdb      : 394:e2078e6f2b3657ae7b67053902eae91a492a54a5
User           : root <root>
Return-Code    : Success
Releasever     : 8
Command Line   : install yum-utils
Packages Altered:
    Install dnf-utils- @BaseOS

See “CentOS / RHEL See Detailed History Of yum history Commands” for info.


You learned how to check and list installed packages using the yum and rpm commands.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

Comments on this entry are closed.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum