The RPM package management system is used to install Linux applications on computers running the Red Hat Enterprise Linux, Fedora, and CentOS Stream operating systems. With RPM, users can install an application from a terminal window by executing nothing more than a single command:
dnf install <package_name>
yum install <package_name>
Most users never need to go beyond using the
yum install commands, which we reviewed in an earlier article, Move from apt to dnf package management. These commands hide the complexity of what's going on underneath the covers during the installation process. But when things go wrong with an installation, it's useful to understand how RPM goes about locating and installing applications, at least for debugging purposes.
You'll learn about those details in this article. You'll see how RPM works with the
.repo files in the directory
/etc/yum.repos.d to locate a package on the internet and then install it on a local computer.
Installing a package from the command line
Installing an RPM package is straightforward. For example, if you want to install the
jq utility that parses and displays JSON, you execute the following command in a terminal window:
dhf install jq
The command will do the work of locating the package out on the internet and installing the
jq utility on the local machine. Using
yum) makes installing RPM packages effortless. But behind that simplicity there's a lot of work going on. The package needs to be located on the internet, downloaded, and then installed. Understanding how this all happens is useful knowledge to have.
What's the difference between dnf and yum?
yum are both command-line utilities used to operate the RPM package management system.
yum (an acronym for Yellowdog Updater, Modified) was the first utility released.
dnf (an acronym for Dandified
yum) is a follow-up technology based on
dnf is the default package management utility for RHEL, Fedora, and CentOS Stream and has been since Fedora 22, CentOS 8, and RHEL 8.
yum has been deprecated as the default package manager in the Red Hat family of distributions, so while
yum commands will work, it's best to start retraining yourself now to using
How RPM discovers and installs a package
yum) finds a package to install by doing a lookup on what is called a repository manifest file. A manifest file might exist locally in the
dnf cache of the local machine, which is where
dnf will look first to find a reference to the package location. If the package reference can't be found there,
dnf install looks in the
.repo files in the directory
/etc/yum.repos.d to get the URL of the repository associated with the
.repo file under examination.
dnf install has the intelligence to parse and analyze the information in the
.repo file to locate the actual manifest file that describes the
.rpm packages stored in the given remote repository.
If there is no reference to the
.rpm file for the package of interest in a particular
dnf install moves on to the next
.repo file in the
/etc/yum.repos.d directory. Once the
.rpm file is located,
dnf install install does the work of installing the package on the local machine (Figure 1).
dnf install can't locate the package reference according to any of the
.repo files hosted on the local machine, the utility will respond with an error.
You can get a list of repositories available on a local machine by executing the follwing command:
$ sudo dnf repolist
dnf repolist command inspects the
.repo files in the
/etc/yum.repos.d directory in order to extract and display the values for
repo id and
repo name. The listing below shows an example of using
dnf repolist to list the repositories known to the local machine.
$ sudo dnf repolist repo id repo name fedora Fedora 35 - x86_64 fedora-modular Fedora Modular 35 - x86_64 updates Fedora 35 - x86_64 - Updates updates-modular Fedora Modular 35 - x86_64 - Updates
.repo files play an important role in listing repositories known to the local machine. Also, information in a
.repo file will eventually lead to discovering the
.repo package that will be installed on the given computer. As you can see,
.repo files are a critical part of the RPM infrastructure.
Putting it all together
The RPM command
dnf install <package_name> makes installing an application on a machine running RHEL, Fedora, or CentOS Stream easy. Before RPM came along, installing applications was a complex, error-prone undertaking. Those days have long since passed. The ease of use that
dnf install facilitates is due to the comprehensive nature of RPM architecture.
dnf install hides a lot going on underneath the covers. Part of this complexity is about how the command parses and analyzes
This article touched upon how RPM uses a
.repo file at high level. The next installment in this series goes into exacting detail about the specified structure of a
.repo file and how that structure relates to the overall RPM management process.