Skip to main content
In this lesson we cover DNF repositories on Red Hat Enterprise Linux 10 (RHEL 10): how DNF uses repositories, how to register a system to access official repos, how to create and manage custom .repo files, and best practices for secure package management. Most software on RHEL 10 is distributed as RPMs and managed with the DNF package manager. Historically administrators used YUM, but on modern systems like RHEL 10, DNF is the standard tool.
A dark presentation slide titled "From YUM to DNF" illustrating migration from legacy YUM to DNF. The left box shows "Legacy YUM — Used on older RHEL releases" with a clock icon, and an arrow points to the right box "Standard Today DNF — The tool to use on RHEL 10" with gear icons.
DNF performs installs, updates, removals, and searches for packages, but it needs repository definitions to know where packages live.
A dark-themed slide titled "What DNF Does and Where It Looks" showing four blue-outlined cards labeled "Install," "Update," "Remove," and "Search," each with a simple icon. The cards are arranged horizontally across the top of the slide on a black background.
Because RHEL is subscription-based, register your system with Red Hat to enable access to the official repositories.
A dark-themed infographic slide titled "Register First, Then You Get Access" showing a highlighted step: "Register the system with Red Hat" inside a rounded box with a key icon and a downward arrow leading toward an "Official Repositories" box. The slide has a minimalist, blue-accented design and a small "Copyright KodeKloud" label in the corner.
If a system is not registered, package installs or updates may fail.
A dark-themed infographic titled "Not Registered? Expect Errors" showing a boxed warning "System not registered" with a downward arrow leading to two boxes labeled "Install fails" and "Update fails."
Registering a RHEL system and attaching a subscription
  • Use Red Hat Subscription Manager to register and auto-attach subscriptions:
Avoid passing passwords on the command line on multi-user systems—commands and arguments may appear in process listings. Omit --password to be prompted interactively.
After successful registration and subscription attachment, the system gains access to Red Hat repositories and DNF can download and manage packages. Listing and inspecting repositories
  • Show enabled repositories:
  • Get verbose repository details (includes base URLs):
  • Show all repositories, including disabled ones:
  • Inspect repository metadata/details:
Enabling or disabling Red Hat-provided repos via Subscription Manager:
Enable or disable repositories using DNF config-manager:

Understanding repository configuration files

Repository definitions are stored in /etc/yum.repos.d. Although DNF is the package manager, the historical directory name is preserved for compatibility. Each repository file must end in .repo and uses INI-style stanzas. Use the table below to quickly reference common .repo fields: Example: a concise Docker CE repository configuration
GPG verification (gpgcheck=1) confirms packages are signed by the provider and have not been tampered with. For development or internal test repositories you may set gpgcheck=0, but avoid disabling signature verification on production systems.

Creating and using a custom repository — step-by-step

Typical workflow when adding a new repository manually:
  1. Create a file under /etc/yum.repos.d that ends with .repo.
  2. Add a repository stanza with an ID, name, baseurl, enabled flag, and GPG settings.
  3. Refresh DNF metadata and cache.
  4. Verify the repository appears in dnf repolist and list packages available from that repo.
  5. Install a package from the repository to validate it works.
Example: creating a Rocky Linux BaseOS repository
After adding or editing a .repo file, refresh metadata and cache:
Sample output (trimmed) showing metadata cache creation:
Verify the repository appears in the repolist:
Example repolist output:
List packages available in a specific repo:
Sample (trimmed) results showing packages from rocky-baseos:
Install a package from the new repository to confirm it works (example installing zsh):
Sample transaction output (trimmed) showing the package resolved from the custom repo:

Enabling and disabling repositories without editing files

Disable a repo temporarily with DNF config-manager:
Re-enable it:
You can also remove a repository permanently by deleting its .repo file or by removing the specific stanza from the file.

Best practices and callouts

Always enable gpgcheck=1 and provide a valid gpgkey for production repositories to ensure package integrity. For test or internal repositories you may temporarily set gpgcheck=0, but never do so on production hosts.
When using RHEL, prefer subscription-manager to enable official Red Hat repositories. Use dnf config-manager or .repo files in /etc/yum.repos.d/ for third‑party or local repositories.

Summary and quick reference

You should now be able to:
  • Register a RHEL system to access official repositories using subscription-manager.
  • List enabled and all repositories with dnf repolist and inspect metadata with dnf repoinfo.
  • Create and edit .repo files in /etc/yum.repos.d.
  • Refresh DNF metadata with dnf clean all and dnf makecache.
  • Enable/disable repos with subscription-manager or dnf config-manager.
  • Install packages from custom repositories and verify their source with dnf list --repo and transaction output.
Links and further reading

Watch Video

Practice Lab