rpm — The Low-Level RPM Package Tool
Practical guide to rpm — the low-level package tool for Red Hat systems: query, install, verify and manage individual RPM packages.
rpm is the low-level tool that sits underneath package managers like dnf and zypper: it installs, removes, and queries individual local .rpm packages on Red Hat-based systems such as Fedora, RHEL, or openSUSE. Unlike dnf, however, rpm does not resolve dependencies – if a required library is missing, the installation simply fails. For everyday work you are better off with dnf; rpm is the right choice when you want to query a single package precisely, inspect an RPM file before installing it, or examine an installed package in detail. This guide walks you through the commands you reach for most: installing, querying, and verifying.
Install & Remove
rpm -ivh <file>.rpm — Install an RPM package (verbose + progress bar).
sudo rpm -ivh package.rpmrpm -Uvh <file>.rpm — Upgrade a package (install if not present).
sudo rpm -Uvh package-2.0.rpmrpm -Fvh <file>.rpm — Freshen: upgrade only if an older version is installed.
sudo rpm -Fvh package-2.0.rpmrpm -e <package> — Remove (erase) an installed package.
sudo rpm -e nginxrpm -e --nodeps <package> — Remove a package ignoring dependencies.
sudo rpm -e --nodeps libfooQuery Installed Packages
rpm -qa — List all installed packages.
rpm -qarpm -qa | grep <pattern> — Search for installed packages.
rpm -qa | grep phprpm -qi <package> — Show detailed info about an installed package.
rpm -qi nginxrpm -ql <package> — List all files installed by a package.
rpm -ql nginxrpm -qc <package> — List only config files of a package.
rpm -qc nginxrpm -qd <package> — List only documentation files of a package.
rpm -qd nginxrpm -qR <package> — List dependencies of a package.
rpm -qR nginxrpm -qf <file> — Find which package owns a file.
rpm -qf /usr/sbin/nginxQuery RPM Files
rpm -qip <file>.rpm — Show info about an uninstalled RPM file.
rpm -qip package.rpmrpm -qlp <file>.rpm — List files inside an RPM file.
rpm -qlp package.rpmrpm -qRp <file>.rpm — Show dependencies of an RPM file.
rpm -qRp package.rpmVerify
rpm -V <package> — Verify installed files against the package database.
rpm -V nginxrpm -Va — Verify all installed packages.
rpm -Varpm -K <file>.rpm — Check the signature and integrity of an RPM file.
rpm -K package.rpmrpm --import <key> — Import a GPG public key for package verification.
sudo rpm --import https://example.com/RPM-GPG-KEYCommon Patterns
rpm -qa --last | head -20 — Show the 20 most recently installed/updated packages.
rpm -qa --last | head -20rpm -qa --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' — Custom formatted package list.
rpm -qa --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' | sortrpm2cpio <file>.rpm | cpio -idmv — Extract files from an RPM without installing.
rpm2cpio package.rpm | cpio -idmv Conclusion
rpm gives you full, direct control over individual packages – along with the responsibility that comes with it. Because rpm does not resolve dependencies, you should normally use dnf (or zypper on openSUSE) for installing and updating, and reserve rpm for targeted queries, verification, and extracting individual files. Be especially careful with -e/--erase (it removes packages) and with --nodeps and --force: they bypass the safety nets and can leave your system in an inconsistent state. Always check downloaded packages before installing with rpm -K (GPG signature), and import the source's keys beforehand via rpm --import.
Further Reading
- rpm.org – the official project site of the RPM Package Manager
- RPM documentation (rpm.org) – reference, manuals, and man pages for the package manager