How to List Installed Packages on CentOS with Yum or RPM

Introduction

Managing a CentOS operating system often means knowing the software packages that are installed. This list can be used for rolling out software updates, rebuilding an operating system, or even duplicating a work environment on another machine.

This guide provides three simple methods to list installed software packages on CentOS (and other RedHat-based Linux systems).

how to list installed packages on centos

Prerequisites

  • Access to a user account with sudo or root privileges
  • A terminal window or command line
  • The YUM and RPM package managers, included by default

How to List Installed Packages with YUM

YUM stands for Yellowdog Updater, Modified. It is an updated package manager that allows you to install, remove, update, view, or search software packages.

Use the following yum command  to display all installed packages:

sudo yum list installed

To check if a specific package is installed with YUM, filter the output with the grep command:

sudo yum list installed | grep xorg
terminal yum list packages command with grep


To display the details on a particular package with YUM:

yum info httpd
terminal with yum info command


YUM can also output the full package list to a file:

sudo yum list installed > listed_packages.txt

This file can be copied to another system to duplicate the installed packages:

sudo yum –y install $(cat listed_packages.txt)
  • The –y option answers yes to all installation prompts
  • The cat command concatenates the contents of the file into the yum install command

For more information on the yum command, use yum ––help.

List Installed Packages with RPM

RPM stands for RedHat Package Manager. It comes as standard with most Red-Hat-based Linux operating systems, such as CentOS and Fedora.

To display a list of installed packages, enter the following in a terminal window:

sudo rpm –qa
  • The –q option means query
  • The –a option means all

To list packages by installation date, enter:

sudo rpm –qa ––last

Search for a package by name using:

sudo rpm –qa | grep –i httpd

This command returns results for the Apache software.

Output the list of packages to a file by entering the following:

sudo rpm –qa > listed_packages.txt

This command saves a copy of the list in a text file called listed_packages.txt in the current working directory.

Display information about a particular package:

rpm –qi httpd
  • The –q option stands for query
  • The –i option stands for info

Count the total number of packages installed:

sudo rpm –qa | wc –l
  • The wc command creates a word count
  • The –l option counts the number of lines
terminal with rpm wc command

RPM lists packages by their package name and revision number. Text-wrapping can make this tool harder to read. Use the rpm ––help command for more options, or refer to the documentation.

List Installed Packages with yum-utils

Yum-utils is a software package that adds functionality to the standard YUM package manager.

To install the yum-utils software package enter:

sudo yum –y install yum-utils

List all installed packages with the repoquery command:

sudo repoquery –a ––installed

The yum-utils package uses yum repositories to pull information.

Conclusion

Now you understand how to list and filter installed packages on CentOS. This guide provided three methods (YUM, RPM, or yum-utils) for listing packages on YUM based Linux distributions.

If you want to find out more on RPM and YUM, read our article and find out how RPM and YUM differ.

Was this article helpful?
YesNo
Goran Jevtic
Goran combines his leadership skills and passion for research, writing, and technology as a Technical Writing Team Lead at phoenixNAP. Working with multiple departments and on various projects, he has developed an extraordinary understanding of cloud and virtualization technology trends and best practices.
Next you should read
How to Install Node.js and NPM on CentOS 7
June 29, 2019

Node Package Manager (npm) is Node's official package manager, used for installing and managing package...
Read more
How to List Users in Linux, List all Users Command
August 4, 2022

Linux OS is unique because of its multiuser characteristic. It allows multiple users on one system, at the...
Read more
How To Use grep Command In Linux/UNIX
March 28, 2019

This guide details the most useful grep commands for Linux / Unix systems. After going through all the ...
Read more
How to use apt Package Manager on Ubuntu Linux
January 7, 2019

In Linux, special tools were developed for managing applications. Application software for Linux typically ...
Read more