Linux rpm Command: Inspect RPM Packages and the Installed Database

rpm queries, verifies, and manages RPM format package files and the installed package database. For general installation that resolves repository packages and dependencies together, dnf is preferred.

-q queries installed packages, and when used with -p, it queries information of RPM files that have not been installed yet. -V compares installed files with the package database information. Even if there are modifications, they may be administrator-modified configuration files, so do not conclude a breach solely based on the output.

Basic syntax

rpm [operation] [option] package or file

Installed implementations and options may vary depending on the distribution. Check the description of your current system with man rpm.

Examples

Check the installed package version

Queries installation status and version from the RPM database.

rpm -q bash

View files included in a package

Checks the paths provided by installed packages.

rpm -ql bash

Viewing local RPM information before installation

Check the name, version, and architecture of the received file. You should also separately verify the file's source and signature.

rpm -qpi ./example.rpm

Querying the Installed RPM Database

rpm -q queries the local RPM database. By fixing the output format, it becomes easier to reliably read package names in scripts.

rpm -q --qf '%{NAME}\n' bash

If bash is installed, example output:

bash

If it is not installed, a query failure message and a non-zero exit status will appear. rpm handles individual packages and the database, but for resolving dependencies from repositories and performing installations or upgrades, use dnf or your distribution's package manager. You should also verify the source and signature of RPM files.

Main Options and Format

Options/Format Description
-q Query package or file information.
-p Set an RPM file as the query target instead of an installed item.
-l / -i Display a file list or package description.
-f path Find the package that owns the specified file.
-V Verify installed files against the database.

Precautions when using

rpm -i is not suitable for general installations that require resolving repository dependencies. Avoid forced options that ignore dependency checks or signature verification. Verification output may also show settings modified by the package manager, so you should review any changes. Check the options supported in the RPM version for your distribution.

Frequently Asked Questions

What is the difference between rpm -q and rpm -qp?

rpm -q queries the installed package database, while rpm -qp queries the local RPM file itself.

Official Documentation

You can check the exact behavior of options and implementation-specific differences in the official RPM documentation.