Operations 7 min read

Master RPM: Essential Commands and Real-World Linux Package Management

This guide explains the purpose of the RPM tool, its syntax, common options, parameter usage, and provides practical examples for installing, upgrading, removing, and querying RPM packages on Linux systems.

Open Source Linux
Open Source Linux
Open Source Linux
Master RPM: Essential Commands and Real-World Linux Package Management

rpm: Package Management Tool

rpm is the Red Hat Package Manager, originally created for Red Hat Linux but now widely adopted across many distributions for installing, upgrading, and removing software packages.

Function Options

rpm provides a powerful set of commands that simplify package handling on Linux.

Command Syntax

rpm [options] [arguments]

Option Meanings

-i: Install a package

-v: Show detailed output

-h: Print hash marks during installation (use with -v for better effect)

-c: Query configuration files of an rpm package

-e: Erase (uninstall) a package

-U: Upgrade a package

-a: Query all packages

-f: Find which package a file or command belongs to

-l: List files in a package

-s: Show file status (used with -l)

-p: Query a specific rpm file

-q: Query packages

-R: Show package dependencies

--force: Ignore file and package conflicts

--percent: Show installation progress as a percentage

--nodeps: Do not verify dependencies

--excludedocs: Do not install documentation files

--test: Test installation without actually installing

Parameter Meaning

The parameter refers to the package file that you want to manipulate.

Reference Examples

Example 1: Install an RPM package

// (1) Basic installation
rpm -ivh your-package.rpm

// (2) Force installation, ignoring conflicts
rpm --force -ivh your-package.rpm

// (3) Force installation and ignore dependencies
rpm --force --nodeps -ivh your-package.rpm

Example 2: Install a .src.rpm package

Source RPMs contain the original source code and need to be built before installation. Two methods are shown.

Method 1:

rpm -i your-package.src.rpm
cd /usr/src/redhat/SPECS
rpmbuild -bp your-package.specs   # prepare the build environment
cd /usr/src/redhat/BUILD/your-package/
./configure   # optional configure options
make
make install

Method 2:

rpm -i your-package.src.rpm
cd /usr/src/redhat/SPECS
rpmbuild -bb your-package.specs   # build binary RPM
# The resulting binary RPM appears in /usr/src/redhat/RPM/<arch>
# Install it with:
rpm -i new-package.rpm

Example 3: Uninstall an RPM package

// (1) Simple removal
rpm -e your-package.rpm

// (2) Force removal when other packages depend on it
rpm -e --nodeps your-package

Example 4: Query information about RPM packages

// List all installed packages
rpm -qa

// Find packages containing a string (e.g., ftp)
rpm -qa | grep ftp

// Show files belonging to a package
rpm -ql ftp

// Show files in an uninstalled package
rpm -qlp package.rpm

// Display detailed package information
rpm -qi ftp

// Find which package installed a specific file
rpm -qf `which program`

// Show package dependencies
rpm -qR ftp

// List configuration files of a package
rpm -qc crontabs
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSystem Administrationpackage management
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.