Use rpm directly to query installed packages and file ownership, verify
package integrity, validate a local RPM, and perform controlled local install/remove
workflows. Finish by rebuilding the RPM database as a recovery step when state is
inconsistent.
You are working on an RPM-based system where you need low-level package visibility
and repair options without relying on higher-level workflows. Your goal is to use
rpm to query what’s installed, validate ownership of files, verify
package integrity, confirm signatures on a local RPM, install or upgrade it, remove
it cleanly, and perform basic database maintenance.
In production,
rpm
is your source of truth for “what owns this file,” “was this package modified,”
and “is this RPM trustworthy.” Use it to validate state before changes and to
confirm repairs after.
rpm -qi
.
rpm -ql
.
rpm -qf
.
rpm -V
.
rpm -K
.
rpm -qp --info
.
rpm -Uvh
.
rpm -e
.
rpm --rebuilddb
.
rpm -qa
,
rpm -qi
).
rpm -qf
) and is a core troubleshooting primitive.
rpm -V
) and help triage suspected tampering or corruption.
rpm -K
).
rpm -Uvh
) and should be used when repos are unavailable or when you need an exact build.
rpm --rebuilddb
), not a routine step.
rpm -qa | head -n 10
This gives you a fast inventory sample and confirms the RPM database is readable.
bash-5.1.8-3.el9.x86_64
coreutils-8.32-34.el9.x86_64
filesystem-3.16-2.el9.x86_64
glibc-2.34-100.el9.x86_64
grep-3.6-5.el9.x86_64
gzip-1.10-6.el9.x86_64
rpm-4.16.1.3-31.el9.x86_64
shadow-utils-4.9-8.el9.x86_64
vim-minimal-8.2.2637-20.el9.x86_64
which-2.21-29.el9.x86_64
bash
.
rpm -qi bash
Use this when you need install-time context, summary, architecture, and release metadata.
Name : bash
Version : 5.1.8
Release : 3.el9
Architecture: x86_64
Summary : The GNU Bourne Again shell
License : GPLv3+
bash
.
rpm -ql bash
This helps when you need to confirm expected files exist or identify what should exist.
/bin/bash
/etc/skel/.bashrc
/usr/share/man/man1/bash.1.gz
/bin/bash
.
rpm -qf /bin/bash
This is the file-ownership lookup you use during troubleshooting and cleanup.
bash-5.1.8-3.el9.x86_64
bash
.
rpm -V bash
Verification reports unexpected changes. Clean output usually means no differences from packaged state, excluding expected config behavior.
Output lines indicate mismatches (size, permissions, checksum, mtime, etc.). Config files may legitimately differ depending on environment and policy.
Do not install RPMs from unknown sources. If digests or signatures fail, stop and validate the origin and transport path.
rpm -K htop-3.3.0-1.el9.x86_64.rpm
This is a trust check before installation. You want clean digests and a valid signature status.
htop-3.3.0-1.el9.x86_64.rpm: digests signatures OK
rpm -qp --info htop-3.3.0-1.el9.x86_64.rpm
Use this to confirm name, version, and architecture before you install a local file.
Name : htop
Version : 3.3.0
Release : 1.el9
Architecture: x86_64
Summary : Interactive process viewer
sudo rpm -Uvh htop-3.3.0-1.el9.x86_64.rpm
-U
upgrades or installs,
-v
increases detail, and
-h
prints a progress bar. Use this for controlled local installs outside of repo workflows.
Preparing... ################################# [100%]
Updating / installing...
1:htop-3.3.0-1.el9 ################################# [100%]
htop
package.
sudo rpm -e htop
This erases files owned by the package and removes it from the RPM database. Dependency checks may block removal.
Preparing packages...
Erasing : htop-3.3.0-1.el9.x86_64
Verifying : htop-3.3.0-1.el9.x86_64
sudo rpm --rebuilddb
This is a repair step when the RPM database becomes inconsistent or corrupted. Treat it as a recovery operation, not a routine action.
Rebuilding RPM database...
Done.
Drift is not always compromise. Compare against known policy, and pay attention to config files and expected admin changes. Use the output as a triage signal, then validate the specific files.
Do not install the RPM. Validate the source, re-download over a trusted path, and confirm you are checking the correct file. Treat failed checks as an integrity incident until proven otherwise.
The package is required by something else. Identify dependents before removal, or use a higher-level workflow that can resolve dependency changes safely.
This can indicate filesystem problems or a damaged database directory. Confirm disk health and available space, then retry. If the database is severely corrupted, recovery may require backups or vendor guidance.
If you installed a local test RPM, remove it and confirm package state is clean. If you rebuilt the database as part of recovery, verify RPM queries still work normally.
rpm -q htop || true
sudo rpm -e htop || true
rpm -qa | head -n 5
The test package is absent (if installed), and RPM queries complete without database errors.
rpm -qa
: Lists installed packages.
-q
: Query mode.
-a
: Queries all installed packages.
rpm -qi <pkg>
: Shows installed package metadata.
-i
: Displays package information (name, version, release, summary, etc.).
rpm -ql <pkg>
: Lists files installed by a package.
-l
: Lists files for the queried package.
rpm -qf <path>
: Identifies which package owns a file path.
-f
: Queries by file ownership.
rpm -V <pkg>
: Verifies installed package contents against packaged state.
-V
: Verification mode (checksums, permissions, sizes, timestamps, etc.).
rpm -K <file.rpm>
: Validates digests and signatures for a local RPM file.
-K
: Checks package signature and digest information.
rpm -qp --info <file.rpm>
: Queries metadata from an RPM file without installing it.
-p
: Operates on a package file instead of the installed database.
--info
: Displays package information for the file.
rpm -Uvh <file.rpm>
: Installs or upgrades from a local RPM file.
-U
: Upgrades if installed, otherwise installs.
-v
: Verbose output.
-h
: Prints hash marks to show progress.
rpm -e <pkg>
: Removes a package (erase).
-e
: Erases the package and owned files (dependency checks apply).
rpm --rebuilddb
: Rebuilds the RPM database as a recovery operation.
--rebuilddb
: Recreates database indexes from installed package headers.