RPM Basics
Applies to CentOS Stream 9 & 10 / AlmaLinux 9.x & 10.x / Rocky Linux 9.x & 10.x
RPM (Red Hat Package Manager) is the low-level package management tool for EL systems. While DNF is more commonly used for everyday operations, understanding RPM basics is very helpful for querying package information, verifying package integrity, and troubleshooting issues.
What You Will Learn
Section titled “What You Will Learn”- RPM package naming format and structure
- Querying installed package information with
rpm - Installing and verifying RPM files
- The relationship between RPM and DNF
- GPG key verification mechanism
Prerequisites
Section titled “Prerequisites”- A system with EL 9.x installed
- A user account with
sudoprivileges - Familiarity with DNF Basics
RPM Package Naming Format
Section titled “RPM Package Naming Format”Each RPM package filename follows a fixed format:
name-version-release.architecture.rpmUsing nginx-1.24.0-1.el9.x86_64.rpm as an example:
| Part | Value | Description |
|---|---|---|
| Name | nginx | Software name |
| Version | 1.24.0 | Upstream software version |
| Release | 1.el9 | Package release, el9 indicates it is for EL 9 |
| Architecture | x86_64 | Target CPU architecture |
RPM Query Operations
Section titled “RPM Query Operations”RPM’s query capabilities are very powerful and are an essential troubleshooting tool. All query operations begin with rpm -q.
Check Whether a Package is Installed
Section titled “Check Whether a Package is Installed”$ rpm -q nginxnginx-1.24.0-1.el9.x86_64If not installed, the output is:
package nginx is not installedList All Installed Packages
Section titled “List All Installed Packages”$ rpm -qa$ rpm -qa | grep sshopenssh-server-8.7p1-38.el9.x86_64openssh-clients-8.7p1-38.el9.x86_64openssh-8.7p1-38.el9.x86_64$ rpm -qa --last | head -20View Detailed Package Information
Section titled “View Detailed Package Information”$ rpm -qi nginxExample output:
Name : nginxVersion : 1.24.0Release : 1.el9Architecture: x86_64Install Date: Mon 24 Mar 2026 10:00:00 AM CSTGroup : System Environment/DaemonsSize : 1918738License : BSDSignature : RSA/SHA256, Fri 15 Nov 2025 08:00:00 AM CST, Key ID ...Source RPM : nginx-1.24.0-1.el9.src.rpmBuild Date : Fri 15 Nov 2025 06:00:00 AM CSTBuild Host : build.almalinux.orgURL : https://nginx.org/Summary : A high performance web server and reverse proxy serverDescription : Nginx is a web server and a reverse proxy server...List Files in a Package
Section titled “List Files in a Package”$ rpm -ql nginxExample output:
/etc/logrotate.d/nginx/etc/nginx/etc/nginx/conf.d/etc/nginx/conf.d/default.conf/etc/nginx/nginx.conf/usr/lib/systemd/system/nginx.service/usr/sbin/nginx/usr/share/nginx/html/index.html...Find Which Package Owns a File
Section titled “Find Which Package Owns a File”$ rpm -qf /usr/sbin/nginxnginx-1.24.0-1.el9.x86_64$ rpm -qf /etc/ssh/sshd_configopenssh-server-8.7p1-38.el9.x86_64List Only Configuration Files
Section titled “List Only Configuration Files”$ rpm -qc nginxExample output:
/etc/logrotate.d/nginx/etc/nginx/conf.d/default.conf/etc/nginx/fastcgi.conf/etc/nginx/nginx.conf...List Only Documentation Files
Section titled “List Only Documentation Files”$ rpm -qd nginxView Package Dependencies
Section titled “View Package Dependencies”$ rpm -qR nginx$ rpm -q --whatrequires openssl-libsQuery an Uninstalled RPM File
Section titled “Query an Uninstalled RPM File”Adding the -p parameter to the query commands above lets you query .rpm files that have not been installed:
$ rpm -qip ./some-package-1.0-1.el9.x86_64.rpm$ rpm -qlp ./some-package-1.0-1.el9.x86_64.rpmRPM Query Quick Reference
Section titled “RPM Query Quick Reference”| Command | Description |
|---|---|
rpm -qa | List all installed packages |
rpm -q <package> | Check if a package is installed |
rpm -qi <package> | View detailed package information |
rpm -ql <package> | List all files installed by a package |
rpm -qf <file-path> | Find which package owns a file |
rpm -qc <package> | List a package’s configuration files |
rpm -qd <package> | List a package’s documentation files |
rpm -qR <package> | View a package’s dependencies |
rpm -q --last | List packages sorted by installation time |
Installing and Managing RPM Files
Section titled “Installing and Managing RPM Files”Install a Local RPM File
Section titled “Install a Local RPM File”$ sudo rpm -ivh package-1.0-1.el9.x86_64.rpmParameter descriptions:
-i: Install-v: Verbose output-h: Show progress bar
Recommended: Use DNF to Install Local RPMs
Section titled “Recommended: Use DNF to Install Local RPMs”$ sudo dnf install ./package-1.0-1.el9.x86_64.rpmUpgrade an RPM Package
Section titled “Upgrade an RPM Package”$ sudo rpm -Uvh package-1.1-1.el9.x86_64.rpmThe -U parameter behavior: if the package is already installed it upgrades; if not installed it installs.
Remove an RPM Package
Section titled “Remove an RPM Package”$ sudo rpm -e nginxVerifying RPM Packages
Section titled “Verifying RPM Packages”Verify Installed Package Integrity
Section titled “Verify Installed Package Integrity”$ rpm -V nginxIf all files are intact, the command produces no output. If files have been modified, modification markers are displayed:
S.5....T. c /etc/nginx/nginx.confMarker meanings:
| Marker | Description |
|---|---|
S | File size changed |
M | Permissions or file type changed |
5 | MD5 checksum changed |
D | Device number changed |
L | Symbolic link changed |
U | Owner changed |
G | Group changed |
T | Modification time changed |
P | Capabilities changed |
$ rpm -VaGPG Key Verification
Section titled “GPG Key Verification”RPM uses GPG signatures to ensure package authenticity and integrity.
View Imported GPG Keys
Section titled “View Imported GPG Keys”$ rpm -qa gpg-pubkey*$ rpm -qi gpg-pubkey-xxxxxxxx-yyyyyyyyManually Import a GPG Key
Section titled “Manually Import a GPG Key”$ sudo rpm --import https://www.example.com/RPM-GPG-KEY-example$ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-9Verify an RPM File’s Signature
Section titled “Verify an RPM File’s Signature”$ rpm -K package-1.0-1.el9.x86_64.rpmExample output (valid signature):
package-1.0-1.el9.x86_64.rpm: digests signatures OKExample output (invalid signature or key not imported):
package-1.0-1.el9.x86_64.rpm: digests SIGNATURES NOT OKThe Relationship Between RPM and DNF
Section titled “The Relationship Between RPM and DNF”Understanding the division of responsibilities between RPM and DNF is important:
| Feature | RPM | DNF |
|---|---|---|
Install local .rpm files | Supported | Supported |
| Automatic dependency resolution | Not supported | Supported |
| Download and install from repositories | Not supported | Supported |
| Query package information | Supported | Supported |
| Verify file integrity | Supported | Not supported |
| GPG signature verification | Supported | Supported (calls RPM) |
In summary:
- DNF is the high-level package manager, responsible for repository management, dependency resolution, and downloading
- RPM is the low-level package manager, responsible for the actual package installation, querying, and verification
- DNF calls RPM under the hood to perform package installation and removal
For daily use, it is recommended to use DNF for installing, updating, and removing packages, and RPM for querying and verification.
Common Issues
Section titled “Common Issues”rpm -ivh Reports “Failed dependencies”
Section titled “rpm -ivh Reports “Failed dependencies””This means the package has unmet dependencies. Solution:
$ sudo dnf install ./package.rpmFinding Which Package Provides a Command
Section titled “Finding Which Package Provides a Command”$ dnf provides */bin/digExample output:
bind-utils-9.16.23-14.el9.x86_64 : Utilities for querying DNS name serversRepo : baseosMatched from:Filename : /usr/bin/digHow to Extract Files from an RPM Package (Without Installing)
Section titled “How to Extract Files from an RPM Package (Without Installing)”$ rpm2cpio package.rpm | cpio -idmvFurther Reading
Section titled “Further Reading”- DNF Package Management Basics — High-level package management operations
- Repository Management — Manage software repositories
- EPEL and Third-Party Repositories — Access more packages
man rpm— Complete RPM command reference