Skip to main content

LinuxRPMS documentation

Linux RPM Command Guide

The rpm command installs, upgrades, removes and inspects RPM packages on Fedora, Red Hat Enterprise Linux, AlmaLinux, Rocky Linux, openSUSE and other RPM-based distributions. This guide covers the commands you'll use most.

rpm or dnf? rpm works on one package file at a time and does not download missing dependencies. For everyday installs from a repository, use dnf (or zypper on openSUSE). Use rpm to query what's installed, check package files, and install a single .rpm you've already downloaded.

Installing a package

Installing, upgrading and removing packages needs root, so run these with sudo.

sudo rpm -ivh package-name-1.0-1.el9.x86_64.rpm

If rpm reports missing dependencies, install the file with dnf instead, which fetches them for you:

sudo dnf install ./package-name-1.0-1.el9.x86_64.rpm

Upgrading a package

sudo rpm -Uvh package-name-1.1-1.el9.x86_64.rpm

-U upgrades the package, or installs it if it isn't installed yet. To upgrade only packages that are already installed, use -F (freshen):

sudo rpm -Fvh *.rpm

Removing a package

Use the package name, not the file name:

sudo rpm -e package-name

To see what would happen without removing anything, add --test:

sudo rpm -e --test package-name

Querying installed packages

TaskCommand
List every installed packagerpm -qa
Check whether a package is installedrpm -q package-name
Show a package's description, version and vendorrpm -qi package-name
List the files a package installedrpm -ql package-name
List only its configuration filesrpm -qc package-name
List only its documentation filesrpm -qd package-name
Find which package owns a filerpm -qf /usr/bin/ssh
Show what a package needsrpm -qR package-name
Show recent changes to a packagerpm -q --changelog package-name | less
List packages by install date, newest firstrpm -qa --last | head

To search the list of installed packages, pipe it through grep:

rpm -qa | grep -i openssl

Looking inside a package file

Add -p to query an .rpm file you haven't installed yet:

rpm -qip package-name-1.0-1.el9.x86_64.rpm   # description and version
rpm -qlp package-name-1.0-1.el9.x86_64.rpm   # files it would install
rpm -qRp package-name-1.0-1.el9.x86_64.rpm   # what it needs

To unpack the files without installing anything, use rpm2cpio:

rpm2cpio package-name-1.0-1.el9.x86_64.rpm | cpio -idmv

Verifying packages

Check a package's signature

Before installing a package you downloaded, check that it's signed and hasn't been changed:

rpm -K package-name-1.0-1.el9.x86_64.rpm

If the result says the key is missing, import the distribution's signing key first. For example, on AlmaLinux 9:

sudo rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux-9

To list the keys you've already imported:

rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n'

Check installed files

Compare installed files with what the package originally put on disk:

rpm -V package-name   # one package
rpm -Va               # every package (slow)

No output means nothing changed. Otherwise each line starts with codes for what's different, such as 5 (contents), S (size), M (permissions) or T (modification time). A c before the file name marks a configuration file, which is often changed on purpose.

Custom output

--queryformat (or --qf) prints just the fields you want. This lists every package with its version and size, largest first:

rpm -qa --qf '%{SIZE}\t%{NAME}-%{VERSION}-%{RELEASE}\n' | sort -rn | head -20

Run rpm --querytags to see every field you can use.

Troubleshooting

"Failed dependencies"

The package needs other packages that aren't installed. Install it with sudo dnf install ./file.rpm so dnf can fetch them. Avoid --nodeps: it installs the package anyway and usually leaves it broken.

"Package is already installed"

Use -U to upgrade instead of -i. To reinstall the same version, use sudo dnf reinstall package-name.

RPM database errors

If rpm reports a damaged database, rebuild it:

sudo rpm --rebuilddb

Need help?

Looking for a specific package? Sign in to your account and use Search RPMs in the dashboard, or browse the mirror directory. For anything else, email hostmaster@linuxrpms.com.