Introduction

RPM (Red Hat Package Manager) is a powerful package management system used in many Linux distributions, including Red Hat, CentOS, Fedora, and others. It allows users to install, upgrade, and manage software packages on their Linux systems. In this guide, we'll explore 20 practical examples of RPM commands to help you effectively manage packages on your Linux system.

Prerequisites

Before proceeding, ensure you have:

  1. A Linux system with RPM package manager installed
  2. Root access to your system

Practical Examples

  1. Install Package: rpm -ivh package.rpm - Installs a package from a .rpm file.
  2. Upgrade Package: rpm -Uvh package.rpm - Upgrades an existing package to a newer version.
  3. Remove Package: rpm -e package_name - Removes a package from the system.
  4. List Installed Packages: rpm -qa - Lists all installed packages on the system.
  5. Query Package Information: rpm -qi package_name - Displays detailed information about a specific package.
  6. Search for a Package: rpm -q package_name - Searches for a specific package on the system.
  7. List Files in a Package: rpm -ql package_name - Lists all files installed by a package.
  8. Verify Package Integrity: rpm -V package_name - Verifies the integrity of installed files for a package.
  9. List Dependencies of a Package: rpm -qR package_name - Lists all dependencies required by a package.
  10. Extract Files from a Package: rpm2cpio package.rpm | cpio -idmv - Extracts files from a .rpm package.
  11. Show Package Scripts: rpm -q --scripts package_name - Displays pre-installation and post-installation scripts of a package.
  12. Check for Duplicates: rpm -Va - Checks for duplicate files among installed packages.
  13. Verify Signature of a Package: rpm -K package.rpm - Verifies the digital signature of a .rpm package.
  14. Import GPG Key: rpm --import /path/to/gpg_key - Imports a GPG key used for package verification.
  15. Check Disk Space Used by Packages: rpm -q --queryformat "%{SIZE} %{NAME}\n" | sort -nr | less - Displays disk space used by installed packages.
  16. Query Package Changelog: rpm -q --changelog package_name - Displays the changelog of a package.
  17. Query Package Documentation: rpm -qd package_name - Displays documentation files included in a package.
  18. Check for Obsolete Packages: rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} %{ARCH}\n' -a | sort -u - Checks for obsolete packages on the system.
  19. Rebuild RPM Database: rpm --rebuilddb - Rebuilds the RPM package database.
  20. Check for Package Updates: yum check-update - Checks for available updates for installed packages.

Conclusion

These 20 practical examples of RPM commands in Linux will help you effectively manage packages on your Linux system. By mastering these commands, you can install, upgrade, query, and verify packages with ease, ensuring smooth operation of your Linux system.

Was this answer helpful? 0 Users Found This Useful (0 Votes)