Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

How does RPM package discovery work?

October 4, 2022
Bob Reselman
Related topics:
Linux
Related products:
Red Hat Enterprise Linux

Share:

    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>
    

    Or:

    yum install <package_name>
    

    Most users never need to go beyond using the dnf or 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 dnf (or 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?

    dnf and 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 yum.

    Today, 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 dnf.

    How RPM discovers and installs a package

    dnf (or 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 .repo file, 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).

    Diagram showing the process for discovering an RPM package for installation on a local computer.
    Figure 1: The process for discovering an RPM package for installation on a local computer.

    If 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
    

    The 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 .repo files.

    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.

    Last updated: October 7, 2022

    Related Posts

    • Moving from apt to dnf package management

    Recent Posts

    • What's New in OpenShift GitOps 1.18

    • Beyond a single cluster with OpenShift Service Mesh 3

    • Kubernetes MCP server: AI-powered cluster management

    • Unlocking the power of OpenShift Service Mesh 3

    • Run DialoGPT-small on OpenShift AI for internal model testing

    What’s up next?

    cheat sheet cover image

    The Intermediate Linux Cheat Sheet introduces developers and system administrators to more Linux commands they should know.

    Get the free cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue