Skip to content

RPM Tool Usage Guide: From rpm -ivh to yum Equivalent Operations | Installation, Upgrade, Query, and yum Comparison Practice ​

RPM Tool Usage Guide Diagram

1. Introduction ​

RPM (Red Hat Package Manager) is the basic package management tool in Red Hat family Linux distributions (such as RHEL, CentOS, Fedora). It can directly operate .rpm Package files, to complete operations such as installation, upgrade, query, and uninstallation.

Although modern systems prefer to use yum(or dnf) to manage software packages, but understand rpm Command and its relationship with yum the correspondence is still very important for troubleshooting, offline installation, and scripting.

This article will start from commonly used rpm Start with commands and focus on introducing rpm -ivh,rpm -Uvh and other practices, and provide the corresponding yum Equivalent operation method.

2. rpm Common Commands Quick Reference ​

2.1 Installation ​

bash
# Install an RPM package and display detailed information and progress.
rpm -ivh package.rpm

# Parameter description:
# -i, --install     install
# -v, --verbose     Show detailed information
# -h, --hash        Show installation progress (# signs)

Note:rpm -ivh Does not automatically resolve dependencies. If a package has unmet dependencies, it will error out and abort.

2.2 Upgrade ​

bash
# Upgrade an rpm package (install it if not installed)
rpm -Uvh package.rpm

# Parameter description:
# -U, --upgrade     Upgrade (if the package is not installed, perform installation)
# -v, --verbose
# -h, --hash
bash
# Only upgrade installed packages (if not installed, report an error and do not install)
rpm -Fvh package.rpm

# Parameter description:
# -F, --freshen     Only upgrade already installed packages

2.3 Query ​

bash
# Query information about installed packages
rpm -q package_name

# Query the file list of installed packages
rpm -ql package_name

# Find which installed package a file belongs to.
rpm -qf /path/to/file

# Query information about uninstalled RPM packages
rpm -qpi package.rpm

# Query the files contained in an uninstalled RPM package
rpm -qlp package.rpm

2.4 Uninstall ​

bash
# Uninstall installed packages
rpm -e package_name

# Force uninstall (ignore dependency checks, use with caution)
rpm -e --nodeps package_name

2.5 Verification and Signature ​

bash
# Verify the file integrity of installed packages
rpm -V package_name

# Check RPM package signature
rpm --checksig package.rpm

3. Comparison of equivalent operations between rpm and yum ​

yum is an RPM-based package manager that can automatically resolve dependencies. The following table lists rpm Common operations and yum the equivalent command for.

Operationrpm commandyum equivalent commandExplanation
Install local RPM packagerpm -ivh package.rpmyum localinstall package.rpm or yum install ./package.rpmyum will automatically resolve dependencies
Upgrade local RPM packagerpm -Uvh package.rpmyum localupdate package.rpm or yum update ./package.rpmyum automatically resolves dependencies.
Only upgrade installed packagesrpm -Fvh package.rpmyum update package_name(From warehouse)For local packages there is no direct equivalent; you can use yum localupdate
Install the package from the repositoryNot applicable (download required first)yum install package_nameInstall from configured repository
Upgrade the packages in the repositoryNot applicableyum update package_nameUpgrade from repository
Uninstall packagerpm -e package_nameyum remove package_nameyum will handle dependencies
Query installed package informationrpm -q package_nameyum info installed package_namesimilar
Query package file listrpm -ql package_nameyum provides /path/to/file(Reverse)yum has no direct equivalent, can use repoquery -l
Query the package to which the file belongsrpm -qf /path/to/fileyum provides /path/to/fileSimilar
List all installed packagesrpm -qayum list installedSimilar
Clear cacheNot applicableyum clean allOnly yum

Prompt:yum localinstall In newer versions, it has been unified as yum install ./package.rpm, just specify the local path directly.

4. Practical Examples ​

4.1 Installing local packages using rpm ​

bash
# Download an RPM package (example)
wget https://example.com/packages/nginx-1.20.1-1.el7.x86_64.rpm

# Install using rpm
rpm -ivh nginx-1.20.1-1.el7.x86_64.rpm

If a dependency error occurs, for example:

error: Failed dependencies:
    pcre >= 8.32 is needed by nginx-1.20.1-1.el7.x86_64

At this point, switch to yum Installation:

bash
yum install ./nginx-1.20.1-1.el7.x86_64.rpm

yum Will automatically download and install missing dependencies from the repository.

4.2 Using the rpm upgrade package ​

bash
# Upgrade (install if not installed)
rpm -Uvh nginx-1.22.0-1.el7.x86_64.rpm

# Upgrade only the installed nginx
rpm -Fvh nginx-1.22.0-1.el7.x86_64.rpm

corresponding yum Operation:

bash
# Upgrade local packages (automatically resolve dependencies)
yum update ./nginx-1.22.0-1.el7.x86_64.rpm

4.3 Query and Validation ​

bash
# Check whether nginx is installed
rpm -q nginx

# List the files installed by nginx.
rpm -ql nginx

# Check which package a configuration file belongs to
rpm -qf /etc/nginx/nginx.conf

# Verify the integrity of the nginx package files
rpm -V nginx

4.4 Uninstall ​

bash
# Uninstall using rpm
rpm -e nginx

# Uninstall using yum (recommended, handles dependencies)
yum remove nginx

5. Notes and Best Practices ​

  • Prefer using yum/dnf: Unless offline installation, script control, or troubleshooting is required, prefer to use yum, because it can automatically resolve dependencies.

  • rpm -ivh and rpm -Uvh the difference:-i Install only; an error will occur if the package already exists;-U Upgrade or install;-F Only upgrade installed packages.

  • Avoid --nodeps and --force: Forced operations may cause confusion in the system package management state; use only when the consequences are clearly understood.

  • Import GPG key: Before installing third-party rpm packages, ensure that a trusted GPG key is imported, use rpm --import Import.

  • offline environment: Can be used in offline environments yumdownloader or repotrack Download dependencies in advance, then use yum localinstall Installation.

  • Query uninstalled packages: Use rpm -qpi,rpm -qlp You can view package information and file list before installation.

6. Summary ​

rpm is the cornerstone of Linux package management, mastering rpm -ivh,rpm -Uvh,rpm -q,rpm -e and other commands, which can help you handle offline installation and troubleshooting with ease. And yum As a higher-level tool, it is more convenient in dependency handling and repository management. Understanding the equivalence between the two allows flexible selection according to the scenario.

I hope this article helps you use RPM and YUM tools better.

Last updated on11/13/2026, 11:51 AM
@fishfinal | @fishfinals | [email protected]