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.

原创文章,作者:kirin,如若转载,请注明出处:https://blog.ytso.com/223870.html

(0)
上一篇 2022年1月7日
下一篇 2022年1月7日

相关推荐

发表回复

登录后才能评论