The rpm command in Linux: package management .rpm

Introduction

The rpm command is the basic tool for managing packages in .rpm format, used mainly in distributions such as Red Hat Enterprise Linux, CentOS, Fedora and openSUSE. Although today many administrators prefer yum or dnf, knowing rpm allows to perform low-level operations, debugging problems and understanding the internal functioning of the package system.

What is RPM?

RPM means Red Hat Package Manager. Each .rpm file contains the binaries, libraries, configuration files and metadata needed for an application to be installed correctly. Metadata include version information, dependencies, control sum and scripts that run before or after installation.

Installation of packages

To install a .rpm package the option is used-i(install). For example:

  • rpm -ivh nombre_paquete.rpm

The flagvshows the process in detail andhprint hash marks to indicate progress. If the package is already installed, rpm rejects the operation unless the option is added--replacepkgsto overwrite the existing version.

Upgrade and freshen

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

  • rpm -Uvh nombre_paquete.rpm

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

Consultation and verification

RPM allows to consult the installed package database. With-q(query) information on a specific package can be obtained:

  • rpm -q nombre_paquete
  • rpm -qi nombre_paqueteshows full details
  • rpm -ql nombre_paquetelist all files that belong to the package

To verify the integrity of an installed package is used-V(check). This option compares the current attributes of the files with those expected and reports any discrepancy:

  • rpm -V nombre_paquete

Packing

Delete a package is made with the option-e(erase). RPM shall verify that there are no other applications that depend on it before proceeding:

  • rpm -e nombre_paquete

If you need to force elimination despite the dependencies, you can add--nodepsalthough this practice is not recommended in production systems.

Management of units and use of yum / dnf

RPM itself does not automatically solve dependencies; if a package requires other libraries, the installation will fail until these dependencies are met manually. Therefore, in practice, frontrends are used asyum(in RHEL 6 and CentOS 6) ordnf(in Fedora and RHEL 8 +), which call rpm internally and are responsible for downloading and solving dependencies from the configured repositories.

However, knowing rpm is useful when working with local packages, creating custom packages or testing is needed in an isolated environment.

Good practices

  • Always check the GPG signature of a package before installing it:rpm -K nombre_paquete.rpm
  • Use the flagsvhfor legible output during installation or update.
  • Keep a backup of the rpm database (/var/lib/rpm) before carrying out mass operations.
  • Prefer yum or dnf for routine management and reserve rpm for low level tasks or debugging.

Conclusion

The rpm command remains a fundamental part of the Linux ecosystem in Red Hat-based distributions. Dominating your options gives you precise control over the installation, updating, consultation and removal of .rpm packages, complementing top level tools such as yum and dnf. With the right knowledge, you can manage systems more safely and efficiently.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish