Introduction
Software installation and package management are essential tasks for Linux administrators and developers. Linux distributions use different package management systems, and RPM-based distributions commonly use the RPM package format.
The rpm command provides a low-level way to work directly with RPM packages. It allows administrators to install software packages, remove applications, inspect package information, verify installed files, and query package databases.
Understanding the RPM command is particularly useful when working with distributions such as Red Hat Enterprise Linux, CentOS, Rocky Linux, AlmaLinux, Fedora, and other RPM-based systems.
What Is RPM in Linux?
RPM originally stood for Red Hat Package Manager and is now commonly referred to as the RPM Package Manager.
An RPM package normally has a .rpm file extension and contains software along with metadata such as:
Package name
Version
Architecture
Dependencies
Installation information
Configuration and documentation files
The rpm command lets you work directly with these packages.
A basic example is:
rpm -ivh package.rpm
This installs an RPM package on a compatible Linux system.
RPM Command Syntax
The general syntax is:
rpm [options] [package]
For example:
rpm -qa
This queries the RPM database and displays installed packages.
The exact options you use depend on whether you want to install, remove, query, upgrade, or verify a package.
Check Whether RPM Is Installed
You can check whether the RPM command is available by running:
rpm --version
You may see output similar to:
RPM version 4.x.x
The exact version depends on your Linux distribution.
Install an RPM Package
To install a local RPM package, use:
rpm -i package.rpm
The -i option means install.
For example:
rpm -i nginx.rpm
You can also use verbose and hash-progress output:
rpm -ivh nginx.rpm
Here:
-i installs the package
-v enables verbose output
-h displays progress indicators
Upgrade an RPM Package
The -U option is used to upgrade a package:
rpm -U package.rpm
A common form is:
rpm -Uvh package.rpm
This can install the package if an older version is not already installed and upgrade it when an earlier version exists.
Remove an RPM Package
To uninstall an installed package:
rpm -e package-name
The -e option means erase.
For example:
rpm -e nginx
Notice that you generally specify the installed package name rather than the .rpm filename.
Before removing software, it is a good practice to understand whether other applications depend on it.
List Installed RPM Packages
You can display all installed RPM packages with:
rpm -qa
The -q option means query, while -a means all.
This command can return a long list, so you can combine it with other Linux commands:
rpm -qa | grep nginx
This searches the installed package list for packages containing nginx.
Query a Specific Package
You can check whether a particular package is installed:
rpm -q nginx
If it is installed, RPM displays its package name and version.
If it is not installed, RPM reports that the package is not installed.
Display Package Information
To view detailed information about an installed package:
rpm -qi nginx
The output can include information such as:
Package name
Version
Release
Architecture
Installation date
Vendor
Packager
Description
This is useful when troubleshooting software versions or confirming what is installed on a server.
Query Information From an RPM File
You can inspect a package file before installing it:
rpm -qip package.rpm
The -p option tells RPM to query the package file rather than the installed package database.
This is useful when you want to understand what a package contains before installation.
List Files Installed by a Package
You can find the files associated with an installed package using:
rpm -ql nginx
This can help you identify:
Configuration files
Executables
Libraries
Documentation
Service-related files
For example, when troubleshooting an application, knowing where its configuration files are installed can save considerable time.
Find Which Package Owns a File
You can determine which installed RPM package owns a particular file:
rpm -qf /usr/bin/example
This is useful when you encounter an unfamiliar executable or configuration file and want to determine which package provided it.
List Files in an RPM Package
You can inspect the contents of a package file before installing it:
rpm -qlp package.rpm
This lets you see which files the RPM is designed to install.
It is particularly useful for reviewing third-party packages before deployment.
Verify an Installed Package
RPM can verify installed package files using:
rpm -V package-name
For example:
rpm -V nginx
Verification compares installed files against information stored in the RPM database.
It can help identify changes to files after installation.
This can be useful when investigating unexpected configuration changes or possible filesystem modifications.
Verify All Installed Packages
You can verify all installed RPM packages with:
rpm -Va
This can generate a large amount of output, especially on a production server with many installed packages.
For that reason, targeted verification is often easier to interpret.
Check Package Dependencies
You can view the dependencies required by an RPM package with:
rpm -qpR package.rpm
For an installed package, you can use:
rpm -qR package-name
This helps you understand what libraries, utilities, or other packages a piece of software expects to have available.
Check Package Requirements
RPM also allows you to query package requirements and capabilities.
For example:
rpm -q --requires package-name
This can help when troubleshooting why a package cannot be installed or run correctly.
Check Package Dependencies Before Installation
One important limitation of using the rpm command directly is dependency management.
Suppose you run:
rpm -ivh application.rpm
and the package requires another library that is not installed.
RPM may report a dependency error.
For example:
error: Failed dependencies:
some-library is needed by application
In this situation, you need to install the required dependencies or use a higher-level package manager.
RPM and DNF
On modern RPM-based distributions, DNF is commonly used as a higher-level package management tool.
For example:
sudo dnf install package-name
DNF can resolve dependencies from configured repositories, making it more convenient for normal software installation.
The distinction is useful:
rpm works directly with RPM packages and the RPM database.
dnf provides higher-level package management and dependency resolution.
You may therefore use RPM for package inspection and low-level operations while relying on DNF for routine software installation and updates.
RPM and YUM
Older Red Hat-based systems commonly used YUM as the higher-level package manager.
For example:
sudo yum install package-name
On many modern systems, YUM functionality is provided through DNF-compatible tooling.
The underlying RPM package format remains important even when administrators primarily use DNF or YUM.
Search Installed Packages
You can combine RPM with grep to find packages matching a particular name:
rpm -qa | grep php
This is useful for quickly identifying installed PHP-related packages.
You can similarly search for:
rpm -qa | grep mysql
or:
rpm -qa | grep python
Determine Package Version
To check the installed version:
rpm -q package-name
For detailed information:
rpm -qi package-name
Knowing the exact installed version can be important when troubleshooting compatibility, security updates, and application behavior.
Determine Package Architecture
You can use:
rpm -qi package-name
to view package architecture.
Common architectures include:
x86_64
aarch64
Other architecture-specific formats
Architecture compatibility should be considered before installing an RPM package manually.
RPM Package Naming
An RPM filename often contains several pieces of information.
For example:
application-2.5.1-1.x86_64.rpm
The filename can communicate:
Package name
Version
Release
CPU architecture
The exact naming convention can vary by package and distribution.
Install a Local RPM Package Carefully
When installing a downloaded RPM, first inspect it:
rpm -qip package.rpm
Then check its contents:
rpm -qlp package.rpm
You can also inspect its dependencies:
rpm -qpR package.rpm
After reviewing the package, install it if appropriate:
sudo rpm -ivh package.rpm
This workflow provides greater visibility than immediately installing an unfamiliar package.
Common RPM Errors
Package Is Already Installed
You may encounter an error when attempting to install a package version that is already present.
Check the installed package:
rpm -q package-name
Then determine whether you actually need an upgrade.
Failed Dependencies
A common problem is:
Failed dependencies
This means one or more required dependencies are unavailable.
On systems using DNF, you can often use:
sudo dnf install ./package.rpm
This can allow the package manager to resolve dependencies from configured repositories.
Package Architecture Is Incompatible
An RPM built for one architecture may not be suitable for another.
Check the package information:
rpm -qip package.rpm
Look at the architecture before installing.
Package File Not Found
If Linux cannot find your RPM file, check your current directory:
pwd
Then list files:
ls
You can also provide the full path:
rpm -ivh /path/to/package.rpm
RPM in Server Administration
RPM is especially useful when managing Linux servers because administrators often need to know exactly which software versions and files are installed.
Common administrative tasks include:
Checking installed packages
Auditing package versions
Identifying package ownership
Verifying modified files
Reviewing package dependencies
Installing local RPM files
Removing obsolete packages
Troubleshooting software installations
These operations can be incorporated into server maintenance and troubleshooting workflows.
RPM in DevOps
RPM also has a place in DevOps environments.
Organizations may build RPM packages as part of their software delivery process and deploy those packages across development, staging, and production systems.
A package-based deployment approach can provide:
Consistent software versions
Repeatable deployments
Dependency metadata
Easier rollback strategies
Centralized package management
Better infrastructure automation
RPM packages can be integrated into automated deployment pipelines where the target operating systems support the RPM ecosystem.
Best Practices for Using RPM
Follow these practices when working with RPM packages:
Verify the package source before installing it.
Inspect an unfamiliar RPM before installation.
Check the package architecture.
Review dependencies.
Prefer DNF for normal dependency-aware package installation.
Use rpm -q and rpm -qi to investigate installed software.
Use package verification when troubleshooting unexpected changes.
Avoid forcibly bypassing dependency checks unless you fully understand the consequences.
Keep production packages consistent across environments.
Maintain backups before making significant changes to production systems.
Frequently Asked Questions
What is the RPM command used for?
The RPM command is used to install, upgrade, remove, query, and verify RPM packages on compatible Linux systems.
How do I install an RPM package?
Use:
rpm -ivh package.rpm
For dependency-aware installation on modern RPM-based systems, a higher-level package manager such as DNF is often preferable.
How do I uninstall an RPM package?
Use:
rpm -e package-name
How do I list installed RPM packages?
Use:
rpm -qa
How do I check an RPM package version?
Use:
rpm -q package-name
Can RPM automatically install dependencies?
The low-level rpm command does not provide the same repository-based dependency resolution experience as DNF. When dependency resolution is needed, use the distribution's higher-level package manager.
Conclusion
The RPM command in Linux is an important tool for managing and inspecting software packages on RPM-based distributions. It provides administrators with direct access to package installation, removal, querying, verification, and dependency information.
While modern administrators often rely on DNF for routine package management, understanding RPM remains valuable for troubleshooting, inspecting package files, auditing installed software, and working with manually distributed RPM packages.
A strong understanding of RPM can also help developers and DevOps teams create more reliable Linux deployment workflows and maintain consistent software environments.
Solace Infotech's sitemap includes RPM as one of its Linux-focused technical resources, alongside topics such as rmdir, scp, vi, and other Linux commands.