Centos 7 List Installed Rpms

admin6 April 2024Last Update :

Understanding RPM Package Management in CentOS 7

RPM stands for Red Hat Package Manager, which is a powerful and versatile tool for managing software packages in Red Hat-based distributions like CentOS. RPM makes it easy to install, update, query, verify, and remove software packages. CentOS 7, being a popular server operating system, relies heavily on RPM for package management, and understanding how to list installed RPMs is crucial for system administration and maintenance.

Listing Installed RPMs with the rpm Command

The primary tool for interacting with RPM packages on CentOS 7 is the rpm command. This command-line utility provides a multitude of options to work with packages, including the ability to list all installed RPMs.

Basic Listing of Installed Packages

To get a basic list of all installed RPM packages on a CentOS 7 system, you can use the following command:

rpm -qa

This command will output a list of all installed packages, typically sorted alphabetically. The -q flag stands for query, and the -a flag means all, indicating that you want to query all installed packages.

Enhanced Listing with Additional Information

For more detailed information about installed packages, you can enhance the output by adding other options to the rpm command:

rpm -qa --info

This command provides a detailed description of each package, including the name, version, release, architecture, group, size, license, signature, source RPM, build date, build host, install date, and summary.

Customizing the Output Format

You can customize the output format of the rpm command to display specific package attributes using the –queryformat option. For example:

rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}n"

This format will list installed packages with their name, version, release, and architecture, each on a new line.

Using yum to List Installed Packages

While rpm is the underlying package manager, CentOS 7 also comes with yum, a higher-level tool that wraps around rpm and provides additional features. Yum stands for Yellowdog Updater Modified and is used for easier package management.

List Installed Packages with yum

To list installed packages using yum, you can execute:

yum list installed

This command will display the installed packages along with their version and repository information.

Searching for a Specific Installed Package

If you’re looking for a specific package, you can use yum to search through the installed packages:

yum list installed | grep package_name

Replace package_name with the name of the package you’re searching for. This will filter the list and show only the packages that match your search criteria.

Advanced RPM Queries and Operations

For system administrators and power users, RPM offers advanced querying capabilities that can be extremely useful for in-depth package management.

Finding Configuration Files for Installed Packages

To find out which configuration files are associated with a particular package, use:

rpm -qc package_name

Replace package_name with the actual name of the package. This command will list only the configuration files from the installed package.

Verifying Installed Packages

The RPM package manager includes a verification feature that can be used to diagnose issues with installed packages:

rpm -V package_name

This command will verify the package against its original state and report any differences in files, permissions, and other attributes.

Managing RPM Package Repositories

CentOS 7 uses repositories to manage access to software packages. Understanding how to list and manage these repositories is key to maintaining a healthy system.

Listing Enabled Repositories

To list all enabled repositories on your CentOS 7 system, you can use the yum command:

yum repolist enabled

This will show you a list of repositories that yum will use to install and update packages.

Adding and Removing Repositories

Adding new repositories can expand the range of software available to your system, while removing repositories can be useful for streamlining package sources or troubleshooting conflicts.

FAQ Section

How can I list only the names of installed RPM packages?

To list only the names of installed packages, you can use the rpm command with a custom query format:

rpm -qa --queryformat "%{NAME}n"

Can I use rpm to install new packages?

Yes, you can use the rpm command to install new packages with the -i option. However, it is generally recommended to use yum for installations because it automatically resolves dependencies.

How do I find out which package provides a specific file?

To find out which installed package provides a specific file, use the rpm command with the -qf option followed by the file path:

rpm -qf /path/to/file

Is it possible to list packages installed on a specific date?

While there is no direct command to list packages by install date, you can use the –last option with rpm to list packages in the order they were installed:

rpm -qa --last

How can I remove an installed RPM package?

To remove an installed package, use the rpm command with the -e option:

rpm -e package_name

Replace package_name with the name of the package you wish to remove. Be cautious when removing packages, as it may affect other system components.

References

Leave a Comment

Your email address will not be published. Required fields are marked *


Comments Rules :