DNF (Dandified YUM) is the default package manager on RHEL 8, replacing the older yum command with improved dependency resolution, transaction history, and modular package support through AppStream. Whether you are installing software, managing module streams, or adding third-party repositories like EPEL, dnf is the single tool for the job. This tutorial covers daily package management workflows, working with AppStream modules, configuring repositories, and tuning dnf behavior via its configuration file.

Prerequisites

  • A RHEL 8 system with root or sudo access
  • A valid Red Hat subscription or CentOS Stream 8 / AlmaLinux 8 / Rocky Linux 8 equivalent repository configuration
  • Network access to package repositories

Step 1 — Core Package Operations

The most frequently used dnf commands cover installing, removing, updating, searching, and inspecting packages.

# Install a package
dnf install -y wget

# Install multiple packages at once
dnf install -y curl git unzip

# Remove a package (and unused dependencies)
dnf remove -y wget

# Update a specific package
dnf update -y curl

# Update all packages on the system
dnf update -y

# Search for packages by name or summary
dnf search nginx

# Display detailed information about a package
dnf info nginx

# Check which package provides a specific file or command
dnf provides /usr/bin/nmcli

Step 2 — Using dnf History to Undo and Redo Transactions

dnf records every transaction in a history database, making it possible to review past operations and roll back unintended changes.

# List all past dnf transactions
dnf history list

# View details of a specific transaction (e.g., transaction ID 5)
dnf history info 5

# Undo a specific transaction (rolls back installs/removals)
dnf history undo 5

# Redo a previously undone transaction
dnf history redo 5

# Undo the most recent transaction
dnf history undo last

Use dnf history undo with caution in production environments — verify the transaction details with dnf history info before rolling back.

Step 3 — Working with AppStream Modules

RHEL 8 introduced AppStream, which delivers software as versioned module streams. This lets you install specific versions of a package (such as Node.js 14 or PHP 7.4) independently of the base OS release.

# List all available modules and their streams
dnf module list

# List available streams for a specific module
dnf module list nodejs

# Enable and install a specific module stream and profile
dnf module install -y nodejs:14/common

# Install the default profile of a module
dnf module install -y postgresql:12

# Show which module stream is currently enabled
dnf module info nodejs

# Reset a module to remove the enabled stream
dnf module reset nodejs

# Disable a module entirely
dnf module disable nodejs

Step 4 — Installing Package Groups and Listing Repositories

Package groups bundle related software into logical sets. Repositories can be listed and managed with dnf without editing .repo files manually.

# List all available package groups
dnf group list

# List hidden groups as well
dnf group list --hidden

# Install the "Development Tools" group (gcc, make, etc.)
dnf group install -y "Development Tools"

# Remove a group
dnf group remove "Development Tools"

# List all enabled repositories
dnf repolist

# List all repositories including disabled ones
dnf repolist --all

# Enable a specific repository temporarily
dnf --enablerepo=epel install -y htop

Step 5 — Adding the EPEL Repository

EPEL (Extra Packages for Enterprise Linux) provides thousands of additional packages not included in the official RHEL repositories. On RHEL 8, install EPEL 8 via the epel-release package available through the RHEL extras or CRB (CodeReady Builder) channel.

# Enable the CodeReady Linux Builder (CRB) repository first (required for some EPEL deps)
dnf config-manager --set-enabled codeready-builder-for-rhel-8-$(arch)-rpms

# On CentOS Stream 8 / AlmaLinux 8 / Rocky Linux 8, enable PowerTools/CRB instead:
# dnf config-manager --set-enabled powertools

# Install the EPEL 8 release package
dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

# Verify EPEL is now listed
dnf repolist | grep epel

# Install a package from EPEL (e.g., htop)
dnf install -y htop

Step 6 — Cleaning Caches and Configuring dnf.conf

Over time, cached package data can consume significant disk space. The /etc/dnf/dnf.conf file controls global dnf behavior such as caching policy, parallelism, and best-practices enforcement.

# Remove all cached package data and metadata
dnf clean all

# Remove only cached package files, keep metadata
dnf clean packages

# Rebuild the repository metadata cache
dnf makecache

# View the main dnf configuration file
cat /etc/dnf/dnf.conf

# Useful settings to add or adjust under [main]:
# gpgcheck=1         (always verify package signatures)
# installonly_limit=3  (keep 3 kernel versions max)
# clean_requirements_on_remove=True
# max_parallel_downloads=10
# fastestmirror=True   (select fastest available mirror)

Conclusion

You now have a thorough understanding of package management with dnf on RHEL 8, from basic install and remove operations to AppStream module streams, group installs, EPEL configuration, and cache management. The transaction history system provides a safety net for rolling back accidental changes, and /etc/dnf/dnf.conf allows you to tune dnf behavior to match your environment’s requirements.

Next steps: How to Configure Network Interface Settings with nmcli on RHEL 8, How to Perform a System Security Audit with auditd on RHEL 8, and How to Use journalctl for Systemd Log Analysis on RHEL 8.