Managing software on Linux often requires a clear understanding of how packages are installed, updated, and removed. The RPM Package Manager provides a robust framework for handling these tasks on distributions such as Red Hat, CentOS, and Fedora. This guide explains how to use rpm effectively, covering essential commands and practical workflows for everyday administration.
Understanding RPM and Its Role
RPM is a low-level package manager that keeps a detailed database of every file, configuration, and script associated with installed software. Unlike higher-level tools that resolve dependencies automatically, rpm operates on individual package files with precision. This makes it ideal for verifying system integrity, performing targeted updates, and auditing what is present on a machine.
Installing Packages with rpm
To install a new package, you use the -i option followed by the path to the RPM file. For example, running rpm -ivh package.rpm installs the package while showing verbose output and a progress hash marks. If the package depends on items that are not present, the command will fail, so it is best to confirm prerequisites beforehand.
Handling Dependencies and Conflicts
Because rpm does not resolve dependencies on its own, you may need to manually locate and install required libraries or tools. When a conflict or version mismatch occurs, the output will indicate which files are causing the problem. In such cases, reviewing the existing installation with rpm -q helps you decide whether to remove, downgrade, or replace packages.
Upgrading and Removing Software
Upgrading an existing installation is straightforward with the -U option, which replaces the old package while preserving configuration files when possible. For a clean removal, the -e option erases the package from the system, but it will not delete configuration files automatically. Combining rpm with tools that handle dependencies is often necessary for complex updates.
Querying Package Information
You can list installed packages with rpm -qa , which is useful for generating inventories or checking versions. To inspect a specific package, the -q option followed by the package name returns details such as version, release, and architecture. Adding the -i flag shows summary information, while -l lists all files delivered by the package.
Verifying Integrity and Scripts
Verification checks compare the installed files against the metadata stored in the RPM database, helping you detect unauthorized changes. Using rpm -V reports differences in file size, permissions, checksums, and timestamps. You can also review the startup, install, and uninstall scripts associated with a package to understand its behavior during maintenance operations.
Best Practices for Reliable Workflows
Before applying major updates, create backups or snapshots so you can recover quickly if something goes wrong. Prefer signed packages to confirm authenticity and reduce the risk of tampered software. When in doubt, test installations on a non-production system first, then document the exact commands used for future reference.