How to Install an RPM Package in Linux
Managing RPM packages is a core skill for system administrators working with Fedora, Red Hat Enterprise Linux, CentOS, and similar distributions. This guide covers direct and dependency-resolving methods, plus relevant troubleshooting steps—all based on practical field experience.
When Direct RPM Installation is Appropriate
Sometimes, you’ll need to install a package that isn’t available in your system’s repositories (e.g., a vendor-provided .rpm
for a closed-source driver or tool). For example, installing a specific version of google-chrome-stable
outside the default repos. The process isn’t always straightforward: dependency resolution can become a bottleneck.
Step 1: Download the RPM
curl -OL https://download.example.com/sample-package-1.0.2.el9.x86_64.rpm
- Use
curl -OL
to retain the original filename and show download progress. - Always verify the source; avoid third-party mirrors unless absolutely trusted.
Step 2: Verify the Package Integrity (Optional)
Before installation, it’s advisable to check the signature and package metadata. In practice, signature validation is often skipped on internal or trusted network blobs, but isn’t a luxury with external downloads.
rpm -Kv sample-package-1.0.2.el9.x86_64.rpm
# Output example:
# sample-package-1.0.2.el9.x86_64.rpm:
# Header V4 RSA/SHA256 Signature, key ID f4a80eb5: OK
# V4 RSA/SHA256 Signature, key ID f4a80eb5: OK
For more granular insight into the package:
rpm -qpi sample-package-1.0.2.el9.x86_64.rpm
Note: Inconsistent signatures (e.g., “NOT OK”) often indicate proxy corruption or tampering; do not proceed unless expected.
Step 3: Install Using the Low-Level rpm Tool
Direct installs don’t resolve dependencies:
sudo rpm -ivh sample-package-1.0.2.el9.x86_64.rpm
-i
for install-v
for verbose-h
for hash progress-U
will upgrade if already installed
Sample error:
error: Failed dependencies:
libfoo.so.2()(64bit) is needed by sample-package-1.0.2.el9.x86_64
Known Issue: Repetitive rpm
installs trying to fix broken dependencies quickly becomes cyclical—avoid unless scripting or locked-down environments require it.
Step 4: Install with Dependency Resolution (Preferred Method)
For end-user workflows, always use dnf
or (on legacy systems) yum
. These tools manage dependencies by pulling required libraries from enabled repositories.
sudo dnf install ./sample-package-1.0.2.el9.x86_64.rpm
- On RHEL/CentOS 7 and below:
sudo yum localinstall ./sample-package-1.0.2.el7.x86_64.rpm
Why the ./ path?
dnf
treats files with a relative path as local packages, enabling dependency resolution. Omitting ./
may cause dnf
to search only repositories.
Distribution | Dependency-Resolving Command |
---|---|
Fedora, RHEL 8/9+ | sudo dnf install ./package.rpm |
RHEL/CentOS ≤ 7 | sudo yum localinstall ./package.rpm |
Side Note: Corporate firewalls sometimes block internet access for servers. Without repo access, you must manually download and resolve all dependencies by hand—dependency hell in practice.
Step 5: Confirm Installation
Check if the package is present:
rpm -q sample-package
- Returns package version or “package is not installed”.
Determine the binary’s path and version:
which sample-command
sample-command --version
Gap: Not all packages provide commands or user-facing binaries; sometimes they’re libraries or plugins—consult documentation or use rpm -ql sample-package
to list installed files.
Known Operations and Practical Tips
- Remove a package:
sudo rpm -e sample-package
- List all installed RPM packages:
rpm -qa | grep sample
- View installation scripts and triggers:
rpm -q --scripts sample-package
- Batch-upgrade all system packages:
Note: Use with caution on production systems; major upgrades can break custom or legacy workloads.sudo dnf upgrade # Fedora/RHEL 8+ sudo yum update # CentOS/RHEL 7 and below
Non-obvious Tip
When debugging unresolved dependencies, use:
dnf repoquery --requires --resolve ./sample-package-1.0.2.el9.x86_64.rpm
This command details not just metadata, but actual RPMs needed—often clarifying chains of secondary requirements.
Bottom Line
Direct use of rpm -i
offers control, but at significant risk of dependency issues. Wherever possible, use dnf install ./package.rpm
instead; it’s smarter, faster, and reduces post-install surprises. Do not run local RPM installs as root except on trusted files, and, critically, avoid bypassing dependency management unless you know every library is in place.
When installation fails, check firewall, DNS, and dnf repolist
status. Still stuck? Examine /var/log/dnf.log
for more granular error output.
No approach is flawless—sometimes manual intervention or a scratch-built .spec
is required. That's a subject for another day.