Table of Contents
This post shows you how to check and list all installed packages in CentOS Linux server 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
1. Open the terminal app or connect to a remote CentOS server using SSH protocol.
2. Show information about all installed packages on CentOS using the following command:
sudo yum list installed
# sudo yum list installed
Installed Packages
NetworkManager.x86_64 1:1.40.0-1.el8 @baseos
NetworkManager-config-server.noarch 1:1.40.0-1.el8 @baseos
NetworkManager-initscripts-updown.noarch 1:1.40.0-1.el8 @baseos
NetworkManager-libnm.x86_64 1:1.40.0-1.el8 @baseos
NetworkManager-team.x86_64 1:1.40.0-1.el8 @baseos
NetworkManager-tui.x86_64 1:1.40.0-1.el8 @baseos
PackageKit.x86_64 1.1.12-6.el8 @appstream
PackageKit-glib.x86_64 1.1.12-6.el8 @appstream
abattis-cantarell-fonts.noarch 0.0.25-6.el8 @appstream
acl.x86_64 2.2.53-1.el8 @anaconda
adcli.x86_64 0.8.2-12.el8 @baseos
alsa-sof-firmware.noarch 2.1.1-1.el8 @baseos
at.x86_64 3.1.20-12.el8 @baseos
attr.x86_64 2.4.48-3.el8 @anaconda
audit.x86_64 3.0.7-4.el8 @baseos
...
3. Run this command to count all installed packages:
sudo yum list installed | wc -l
# sudo yum list installed | wc -l
578
4. Save or export the list of all installed packages names in a file.
sudo yum list installed > app_list.txt
# sudo yum list installed > app_list.txt
# cat app_list.txt
Installed Packages
NetworkManager.x86_64 1:1.40.0-1.el8 @baseos
NetworkManager-config-server.noarch 1:1.40.0-1.el8 @baseos
NetworkManager-initscripts-updown.noarch 1:1.40.0-1.el8 @baseos
NetworkManager-libnm.x86_64 1:1.40.0-1.el8 @baseos
NetworkManager-team.x86_64 1:1.40.0-1.el8 @baseos
NetworkManager-tui.x86_64 1:1.40.0-1.el8 @baseos
PackageKit.x86_64 1.1.12-6.el8 @appstream
PackageKit-glib.x86_64 1.1.12-6.el8 @appstream
abattis-cantarell-fonts.noarch 0.0.25-6.el8 @appstream
acl.x86_64 2.2.53-1.el8 @anaconda
adcli.x86_64 0.8.2-12.el8 @baseos
alsa-sof-firmware.noarch 2.1.1-1.el8 @baseos
at.x86_64 3.1.20-12.el8 @baseos
attr.x86_64 2.4.48-3.el8 @anaconda
audit.x86_64 3.0.7-4.el8 @baseos
...
5. You can use the grep command as filter too. For example, find out if Python installed or not:
sudo yum list installed | grep python
# sudo yum list installed | grep python
platform-python.x86_64 3.6.8-47.el8 @baseos
platform-python-pip.noarch 9.0.3-22.el8 @baseos
platform-python-setuptools.noarch 39.2.0-6.el8 @anaconda
policycoreutils-python-utils.noarch 2.9-20.el8 @baseos
python3-audit.x86_64 3.0.7-4.el8 @baseos
...
6. Want to list extras packages installed on the system that are not available in any known repository? Let’s run the following command:
sudo yum list extras
# sudo yum list extras
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Extra Packages
MariaDB-client.x86_64 10.5.8-1.el7.centos @mariadb-main
MariaDB-common.x86_64 10.5.8-1.el7.centos @mariadb-main
MariaDB-compat.x86_64 10.5.8-1.el7.centos @mariadb-main
MariaDB-server.x86_64 10.5.8-1.el7.centos @mariadb-main
certbot.noarch 1.9.0-1.el7 @epel
epel-release.noarch 7-13 @epel
gd-last.x86_64 2.3.0-2.el7.remi @remi-safe
libzip5.x86_64 1.7.3-1.el7.remi @remi-safe
libzstd.x86_64 1.4.5-3.el7 @epel
oniguruma5php.x86_64 6.9.6-1.el7.remi @remi-safe
7. Lists all packages known to us.
sudo yum list all
8. Finally, show available packages.
sudo yum list available
# sudo yum list installed | wc -l
578
# sudo yum list all | wc -l
7281
# sudo yum list available | wc -l
6640
Display packages list that needs updates/patching
Keeping your CentOS server secure is an essential task. You can count then get a list of all updates available for the installed packages.
sudo yum list updates | wc -l
sudo yum list upgrades
# sudo yum list updates | wc -l
67
# sudo yum list updates | more
Loaded plugins: langpacks
Updated Packages
WALinuxAgent.noarch 2.7.3.0-1_ol001.el7 openlogic
at.x86_64 3.1.13-25.el7_9 updates-openlogic
bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.10 updates
bind-libs.x86_64 32:9.11.4-26.P2.el7_9.10 updates
bind-libs-lite.x86_64 32:9.11.4-26.P2.el7_9.10 updates
bind-license.noarch 32:9.11.4-26.P2.el7_9.10 updates
bind-utils.x86_64 32:9.11.4-26.P2.el7_9.10 updates
...
Get a list of all installed packages with rpm command
rpm commands to get the list of installed packages in CentOS Linux:
sudo rpm -qa
sudo rpm -qa | wc -l
sudo rpm -qa | grep python
# sudo rpm -qa
sssd-krb5-common-2.7.3-4.el8.x86_64
python3-pysocks-1.6.8-3.el8.noarch
lmdb-libs-0.9.24-1.el8.x86_64
kbd-legacy-2.0.4-10.el8.noarch
kernel-tools-4.18.0-408.el8.x86_64
...
# sudo rpm -qa | wc -l
578
# sudo rpm -qa | grep python
python3-pysocks-1.6.8-3.el8.noarch
python3-sssdconfig-2.7.3-4.el8.noarch
python3-dnf-4.7.0-11.el8.noarch
python3-ptyprocess-0.5.2-4.el8.noarch
python3-setools-4.3.0-3.el8.x86_64
python3-rpm-4.14.3-23.el8.x86_64
...
Use repoquery command from dnf-utils package
First, install yum-utils for CentOS 6/7 or dnf-utils on a CentOS 8 and higher:
###CentOS 6/7
sudo yum -y install yum-utils
###CentOS 8/9
sudo dnf -y install dnf-utils
To check installed packages in CentOS Linux, execute:
sudo yum repoquery -a --installed
# sudo yum repoquery -a --installed
NetworkManager-1:1.40.0-1.el8.x86_64
NetworkManager-config-server-1:1.40.0-1.el8.noarch
NetworkManager-initscripts-updown-1:1.40.0-1.el8.noarch
NetworkManager-libnm-1:1.40.0-1.el8.x86_64
NetworkManager-team-1:1.40.0-1.el8.x86_64
NetworkManager-tui-1:1.40.0-1.el8.x86_64
...
List all available packages providing “webserver”:
sudo yum repoquery --whatprovides webserver
# sudo yum repoquery --whatprovides webserver
Last metadata expiration check: 1:57:40 ago on Sat 29 Oct 2022 07:32:48 AM EDT.
httpd-0:2.4.37-30.module_el8.3.0+462+ba287492.0.1.x86_64
httpd-0:2.4.37-39.module_el8.4.0+778+c970deab.x86_64
httpd-0:2.4.37-40.module_el8.5.0+852+0aafc63b.x86_64
...
Check for installed packages on CentOS and backup.
You can list and backup all installed packages using the following commands:
rpm -qa --qf "%{NAME}\n" | sort > /backup/installed-software.log
cat /backup/installed-software.log
# rpm -qa --qf "%{NAME}\n" | sort > /backup/installed-software.log
# cat /backup/installed-software.log
abattis-cantarell-fonts
acl
adcli
alsa-sof-firmware
at
attr
audit
audit-libs
...
To restore all those packages when needed, run:
sudo yum -y install $(cat /backup/installed-software.log)
The yum command has history option on the latest version of CentOS/RHEL v6.x+. You 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
# sudo yum history
ID| Command line | Date and time | Action(s) | Altered
------------------------------------------------------------------------------------------------
8 | -y install dnf-utils | 2022-10-29 09:28 | Install | 1
7 | -y install xorg-x11-drv-vmware | 2022-10-29 08:15 | Install | 33
6 | -y install open-vm-tools | 2022-10-29 08:05 | Install | 9
5 | distro-sync --allowerasing | 2022-10-29 07:06 | I, U | 325 EE
4 | swap centos-linux centos-stream-repos -y | 2022-10-29 07:03 | E, I, O, U | 6 EE
3 | in centos-release-stream -y | 2022-10-29 07:03 | Install | 1
2 | update -y | 2022-10-29 06:52 | I, O, U | 352 EE
1 | | 2022-10-29 06:41 | Install | 458 EE
We can examine history entries in detail too using ID number from the above outputs:
# sudo yum history info 2
Transaction ID : 2
Begin time : Sat 29 Oct 2022 06:52:27 AM EDT
Begin rpmdb : 452:d36102e930ef4bbc92236148a528801c6096f1f4
End time : Sat 29 Oct 2022 06:59:41 AM EDT (7 minutes)
End rpmdb : 520:d05662ef5736446b6eda0e765739c11b62408ec6
User : root <root>
Return-Code : Success
Releasever : 8
Command Line : update -y
Comment :
Packages Altered:
Install PackageKit-1.1.12-6.el8.x86_64 @appstream
Install PackageKit-glib-1.1.12-6.el8.x86_64 @appstream
Install abattis-cantarell-fonts-0.0.25-6.el8.noarch @appstream
Install bind-libs-32:9.11.26-6.el8.x86_64 @appstream
Install bind-libs-lite-32:9.11.26-6.el8.x86_64 @appstream
Install bind-license-32:9.11.26-6.el8.noarch @appstream
...