The rpm command in Linux: managing .rpm packages

Introduction

The rpm command is the basic tool for managing packages in .rpm format, primarily used in distributions such as Red Hat Enterprise Linux, CentOS, Fedora, and openSUSE. Although nowadays many administrators prefer yum or dnf, knowing rpm allows performing low-level operations, troubleshooting problems, and understanding the inner workings of the package system.

What is RPM?

RPM stands for Red Hat Package Manager. Each .rpm file contains the binaries, libraries, configuration files, and metadata needed for an application to install correctly. The metadata includes version information, dependencies, checksum, and scripts that run before or after installation.

Package Installation

To install a .rpm package, use the -i (install) option. For example:

  • rpm -ivh package_name.rpm

The v flag shows the process in detail and h prints hash marks to indicate progress. If the package is already installed, rpm will refuse the operation unless you add the --replacepkgs option to overwrite the existing version.

Update and Freshen

Updating a package is done with -U (upgrade). This option installs the new version and automatically removes the old one:

  • rpm -Uvh package_name.rpm

If you only want to update packages that are already present on the system, you can use --freshen (option -F), which ignores packages that are not installed.

Query and Verification

RPM allows querying the database of installed packages. With -q (query) you can obtain information about a specific package:

  • rpm -q package_name
  • rpm -qi package_name shows full details
  • rpm -ql package_name lists all files belonging to the package

To verify the integrity of an installed package, use -V (verify). This option compares the current file attributes with the expected ones and reports any discrepancies:

  • rpm -V package_name

Package Removal

Removing a package is done with the -e (erase) option. RPM will check that no other applications depend on it before proceeding:

  • rpm -e package_name

If you need to force removal despite dependencies, you can add --nodeps

This post is also available in ESPAÑOL.

Leave a Reply

Your email address will not be published. Required fields are marked *

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .