rpm Command in Linux: Install, Query, and Verify Packages

The RPM Package Manager (RPM) is a powerful package management system used by Red Hat Enterprise Linux, Fedora, AlmaLinux, Rocky Linux, and their derivatives. RPM also refers to the rpm command and .rpm file format. An RPM package consists of an archive of files and metadata including information such as dependencies and install location.
In this tutorial, we will talk about how to use the rpm command to install, update, remove, verify, query, and otherwise manage RPM packages.
Installing, Updating and Removing RPM Packages
On modern Red Hat based distributions, you will use dnf to install packages from repositories — it resolves and installs all dependencies automatically. On older RHEL 7 systems, yum serves the same purpose.
You should always prefer using dnf (or yum on RHEL 7) over rpm when installing, updating, and removing packages.
Before installing an RPM package, you must first download the package on your system using a browser or command-line tools like curl
or wget
.
When installing RPM packages, make sure they are built for your system architecture and distribution version. Be extra careful when replacing or updating important system packages, like glibc, systemd, or other services and libraries that are essential for the proper functioning of your system.
Only root or users with sudo privileges can install or remove RPM packages.
To install an RPM package with the rpm, use the -i option, followed by the package name:
sudo rpm -ivh package.rpmThe -v option tells rpm to show verbose output and the -h option to show the hash marked progress bar.
It is safer to download the RPM file first and then install it locally. For example:
curl -O https://example.com/package.rpm
sudo rpm -ivh package.rpmTo upgrade an RPM package, use the -U option. If the package is not installed it will be installed:
sudo rpm -Uvh package.rpmIf the package you are installing or updating depends on other packages that are not currently installed, rpm will display a list of all missing dependencies. You will have to download and install all dependencies manually.
To install an RPM package without having all the required dependencies installed on the system, use the --nodeps option:
sudo rpm -Uvh --nodeps package.rpmTo remove (erase) an RPM package, use the -e option followed by the installed package name (not the .rpm filename):
sudo rpm -e package-nameThe --nodeps option is also useful when you want to remove a package without checking its dependencies:
sudo rpm -e --nodeps package-nameThe --test option tells rpm to run the installation or removal command without actually doing anything. It only shows whether the command would work or not:
sudo rpm -Uvh --test package.rpmQuerying RPM Packages
The -q option tells the rpm command to run a query.
To query (search) whether a certain package is installed, pass the package name to the rpm -q command. The following command will show you whether the OpenJDK 11 package is installed on the system:
rpm -q java-11-openjdk-develIf the package is installed you will see something like this:
java-11-openjdk-devel-11.0.4.11-0.el8_0.x86_64Query an Uninstalled RPM File
You can inspect an RPM file before installing it. To show package information from a local file, use:
rpm -qpi package.rpmTo list the files contained in the package without installing it, use:
rpm -qpl package.rpmPass -i to get more information about the queried package:
rpm -qi java-11-openjdk-develTo get a list of all the files in an installed RPM package:
rpm -ql package-nameIf you want to find out which installed package a particular file belongs to, type:
rpm -qf /path/to/fileTo get a list of all installed packages on your system use the -a option:
rpm -qaVerifying RPM Packages
When verifying a package, the rpm command checks whether each file installed by a package exists on the system, the file’s digest, ownership, permissions, etc.
To verify an installed package, use the -V option. For example, to verify the openldap package you would run:
rpm -V openldap-2.4.46-9.el8.x86_64If the verification passes the command will not print any output. Otherwise, if some of the checks fail, it will show a character that indicates the failed test.
For example, the following output shows that the file’s mTime has been changed (“T”):
.......T. c /etc/openldap/ldap.confRefer to the RPM man page about what each character means.
To verify all the installed RPM packages run the following command:
rpm -VaTroubleshooting
Failed dependencies error
The package requires other packages that are not installed. Prefer using dnf install package.rpm so dependencies are resolved automatically instead of forcing installation with --nodeps.
Package is not installed
Check the exact package name with rpm -qa | grep name, then rerun the query or removal command with the installed package name rather than the RPM filename.
Signature or digest check fails
Verify the package source and make sure the appropriate GPG keys are installed. You can inspect signature information with rpm -K package.rpm.
Cannot find which package owns a file
Use the full absolute path with rpm -qf /path/to/file. If nothing is returned, the file may not belong to an installed RPM package.
Quick Reference
| Command | Description |
|---|---|
rpm -ivh package.rpm | Install a package |
rpm -Uvh package.rpm | Install or upgrade a package |
rpm -e package-name | Remove a package |
rpm -Uvh --nodeps package.rpm | Install ignoring dependency checks |
rpm -Uvh --test package.rpm | Test install without making changes |
rpm -q package-name | Check if a package is installed |
rpm -qi package-name | Show detailed package information |
rpm -ql package-name | List all files in a package |
rpm -qf /path/to/file | Find which package owns a file |
rpm -qa | List all installed packages |
rpm -V package-name | Verify an installed package |
rpm -Va | Verify all installed packages |
FAQ
What is the difference between rpm and dnf?dnf (and yum on older systems) installs packages from repositories and resolves dependencies automatically. rpm is a lower-level tool that works with individual .rpm files and does not resolve dependencies — you have to handle them manually.
How do I find which package provides a specific file?
Use rpm -qf /path/to/file to identify the installed package that owns a given file. For example, rpm -qf /usr/bin/python3 will show the package that installed the Python 3 binary.
How do I list all installed RPM packages?
Run rpm -qa to print the full list. To filter it, pipe the output to grep — for example, rpm -qa | grep nginx.
Can I install an RPM without downloading it first?
It is better to download the package first and then install it locally. That gives you a chance to verify the file and avoids relying on URL handling behavior that may vary between environments.
Conclusion
rpm is a low-level command-line tool for installing, querying, verifying, updating, and removing RPM packages. When installing RPM packages, prefer using dnf as it automatically resolves all dependencies for you.
For more information about all available command options type man rpm in your terminal or visit the RPM.org
website.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page