How To Master the RPM Command

How to Master the RPM Command

Introduction

As a Linux user, you've likely encountered RPM (Red Hat Package Manager), a powerful package management system used by various Linux distributions including Red Hat, CentOS, Fedora, OpenSUSE, and more. RPM is known for its simplicity, ease of use, and enhanced security features. In this guide, we'll explore the RPM command and its practical use cases, from installing and upgrading packages to querying and verifying them. Let's get started!

What is RPM?

RPM, or Red Hat Package Manager, is a free and open-source package management system that allows you to install, update, remove, verify, and query RPM packages on your Linux system. RPM packages are stored in repositories, and the RPM command-line tool provides you with easy access to a vast array of software packages. Most RPM packages are binary files with pre-compiled software that are compatible with specific Linux distributions and system architectures.

The Basics: Installing, Updating, and Removing RPM Packages

To manage RPM packages, you'll need to use the rpm command along with specific options. Here are some fundamental commands to get you started:

  • Install: To install an RPM package, use the -i option followed by the package file name. For example:

    sudo rpm -ivh package.rpm

    The -v option provides verbose output, while the -h option shows a progress bar.

  • Upgrade: To upgrade an existing RPM package, use the -U option. The package will be upgraded to a newer version if available:

    sudo rpm -Uvh package.rpm

    If the package has any missing dependencies, RPM will list them, and you'll need to install them manually.

  • Remove: To remove (erase) an installed RPM package, use the -e option followed by the package name:

    sudo rpm -e package_name

    To remove a package without checking its dependencies, use the --nodeps option.

Querying and Verifying RPM Packages

To retrieve information about RPM packages and verify their integrity, you can use the following commands:

  • Query: To query whether a specific package is installed, use the -q option:

    sudo rpm -q package_name

    To get more detailed information, use the -qi option. Additionally, you can use the -ql option to list all the files in the installed package.

  • Verify: To verify the integrity of an installed package, use the -V option:

    sudo rpm -V package_name

    RPM will check file ownership, permissions, and other metadata, and report any discrepancies.

Exploring More RPM Command Examples

RPM offers a wide range of functionalities, and here are a few more practical examples:

  • Display Package Info Before Installing: To view information about a package before installing it, use the -qip option:

    sudo rpm -qip package_name

  • Check Package Dependencies: To check dependencies before installing a package, use the -qpR option:

    rpm -qpR package_name

  • Find Manual Pages: To list available documentation related to an installed package, use the -qdf option:

    sudo rpm -qdf package_name

Conclusion

With the rpm command, you have the power to manage and maintain RPM packages on your Linux system. While RPM is an excellent low-level tool, you may also use yum or dnf package managers for automatic dependency resolution. To explore more advanced options and features, consult the RPM

George Whittaker is the editor of Linux Journal, and also a regular contributor. George has been writing about technology for two decades, and has been a Linux user for over 15 years. In his free time he enjoys programming, reading, and gaming.

Load Disqus comments