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 chown Command: Change File Owner and Group

Linux chown Command: Change File Owner and Group

Learn how to change File Owner and Group with the Linux chown command, including practical examples, key options, and important precautions.

Linux Tutorial / File System Basics: Paths and Key Directories

Linux Tutorial / File System Basics: Paths and Key Directories

Understand the Linux directory tree, read absolute and relative paths, and learn what common directories such as /home, /etc, and /var are used for.

Linux pgrep Command: Find Process IDs by Name or Criteria

Linux pgrep Command: Find Process IDs by Name or Criteria

Learn how to find Process IDs by Name or Criteria with the Linux pgrep command, including practical examples, key options, and important precautions.

Linux dd Command: Copy and Convert Data by Blocks

Linux dd Command: Copy and Convert Data by Blocks

Learn how to copy and convert files or block devices with Linux dd, choose block sizes and ranges, display progress, verify results, and avoid overwriting the wrong device.

Linux pacman Command: Manage Packages on Arch Linux

Linux pacman Command: Manage Packages on Arch Linux

Learn how to manage Packages on Arch Linux with the Linux pacman command, including practical examples, key options, and important precautions.

Linux diff Command: Compare Text Files and Directories

Linux diff Command: Compare Text Files and Directories

Learn how Linux diff compares text files and directories, produces unified patches, ignores selected whitespace changes, and reports differences through exit status.

Linux Tutorial / File Permissions and Safe sudo Use

Linux Tutorial / File Permissions and Safe sudo Use

Learn to read file and directory permissions, practice chmod safely, and understand when to use sudo and how to diagnose access errors.

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 which Command: Find Executables in PATH

Linux which Command: Find Executables in PATH

Learn how Linux which searches PATH for executables, shows all matching paths, differs from type and command -v, and should be used carefully in scripts.

Linux nc Command: Test TCP and UDP Connections

Linux nc Command: Test TCP and UDP Connections

Learn how to test TCP and UDP Connections with the Linux nc command, including practical examples, key options, and important precautions.