×


Commands to list installed rpm packages on Linux

Are you trying to list all installed packages using rpm command on CentOS/Suse/Fedora/RHEL/Scientific and Red Hat Enterprise Linux?

This guide is for you.

RPM command is used for installing, uninstalling, upgrading, querying, listing, and checking RPM packages on your Linux system.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Software Installation Tasks on their Linux Server.
In this context, we shall look into how to list or count installed RPM packages on Linux operating systems.

More information about RPM?

RPM stands for Red Hat Package Manager. With root privilege, you can use the rpm command with appropriate options to manage the RPM software packages.

What is the command syntax to list installed rpm packages in Linux?

The rpm command has an "-a" option to query (list) all installed packages.
To list all installed packages using rpm -a option, start by logging into your Server via an SSH tool such as putty and execute the following command as the root user;

$ rpm -qa

Also, you can decide to list the packages installation date using the command;

rpm -qa --qf '(%{INSTALLTIME:date}): %{NAME}-%{VERSION}\n

How to get information regarding a particular package?

Lets say you want to know more about the set Firewall rules on your server, you can run the command below for the iptables;

$rpm -qi iptables

This will display all the firewall rules implemented on the Server.


How to list all files installed by the RPM package?

To list package files, simply execute the following command:

$ rpm -ql <packagename>

Where "<packagename>" refers to the name of the package you want to list.
Lets say you want to know the installation date of a specific package, for example nginx, simply execute:

rpm -q --last nginx

This will display the installation date of nginx.

How to use yum or dnf to list installed RPM packages on Linux?

To do this, execute, the following grep command or more command as the root user for CentOS server;

$ yum list installed
$ yum list installed | more
$ yum list installed | grep nginx

For Fedora and latest version of the CentOS/RHEL 8.x, simply use the dnf command;

$ dnf list installed
$ dnf list installed | less
$ dnf list installed | grep -i mysql

How to count all installed RPM packages using yum/dnf in Linux?

With the yum and dnf command, you can count installed packages on CentOS or RHEL or SUSE as shown below;

$ yum list installed | wc -l
$ dnf list installed | wc -l

How to list all installed packages in RHEL, CentOS, Oracle and Fedora Linux?

Similarly, you can use the rpmquery command to list installed packages. To begin, you have to install dnf-utils/yum-utils package as shown below;

$ dnf install dnf-utils ## <-- Fedora latest or CentOS/RHEL 8x. -- ##
$ yum install yum-utils ## <-- CentOS/RHEL 6.x/7.x -- ##

Now, to list all installed packages, execute;

$ repoquery -a --installed
$ repoquery -a --installed | grep httpd
$ repoquery -a --installed | more

Also, you can list installed packages from a particular repo such as epel repo on CentOS/RHEL 7 or ELEP repo on RHEL 8 or EPEL repo on CentOS 8.

First, get the repo id, execute:

$ yum repolist

Note down repo id such as base, epel, extras and so on. Finally list all installed packages from epel repo:

yumdb search from_repo reop_id_here
yumdb search from_repo extras
yumdb search from_repo epel

[Need to perform Software Installation task on you Linux Server? We are available to help you today.]


Conclusion

This article will guide you on the different commands to list all installed rpm packages on CentOS, RHEL (Red Hat Enterprise Linux), SUSE/OpenSUSE and other rpm based distros using rpm and dnf/yum command that print a list of all installed packages on your distro.