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.

What is the rpm command?

-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.

More in This Category
Linux time Command: Measure Command Execution Time

Linux time Command: Measure Command Execution Time

Learn how to use the Linux time command to measure elapsed, user CPU, and system CPU time for a command, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux fold Command: Wrap Long Lines at a Fixed Width

Linux fold Command: Wrap Long Lines at a Fixed Width

Learn how to wrap Long Lines at a Fixed Width with the Linux fold command, including practical examples, key options, and important precautions.

Linux apropos Command: Search Commands by Description

Linux apropos Command: Search Commands by Description

Learn how to use the Linux apropos command to find relevant manual pages by searching description keywords, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux uname Command: Check Kernel and System Architecture

Linux uname Command: Check Kernel and System Architecture

Learn how to check Kernel and System Architecture with the Linux uname command, including practical examples, key options, and important precautions.

Linux mount Command: Inspect and Mount Filesystems

Linux mount Command: Inspect and Mount Filesystems

Learn how to inspect and Mount Filesystems with the Linux mount command, including practical examples, key options, and important precautions.

Linux resolvectl Command: Inspect systemd DNS Resolution

Linux resolvectl Command: Inspect systemd DNS Resolution

Learn how to inspect systemd DNS Resolution with the Linux resolvectl command, including practical examples, key options, and important precautions.

Linux paste Command: Join Corresponding Lines Side by Side

Linux paste Command: Join Corresponding Lines Side by Side

Learn how to join Corresponding Lines Side by Side with the Linux paste command, including practical examples, key options, and important precautions.

Linux join Command: Combine Files by a Common Field

Linux join Command: Combine Files by a Common Field

Learn how to combine Files by a Common Field with the Linux join command, including practical examples, key options, and important precautions.

Linux cmp Command: Compare Files Byte by Byte

Linux cmp Command: Compare Files Byte by Byte

Learn how Linux cmp compares two files byte by byte, reports the first mismatch, runs silently in scripts, limits ranges, and differs from diff and checksums.

Linux systemctl Command: Manage systemd Services

Linux systemctl Command: Manage systemd Services

Learn how to manage systemd Services with the Linux systemctl command, including practical examples, key options, and important precautions.