Skip to content

Dnf_yum

Chapter 29: dnf/yum - Red Hat Package Manager Deep Dive

Section titled “Chapter 29: dnf/yum - Red Hat Package Manager Deep Dive”

Mastering Package Management on Red Hat-Based Systems

Section titled “Mastering Package Management on Red Hat-Based Systems”

DNF (Dandified YUM) is the next-generation package manager for RPM-based distributions. It was introduced in Fedora 18 and became the default in Fedora 22, replacing the older YUM. RHEL 8 and CentOS Stream also use DNF as the default package manager.

RPM Package Management Evolution
+------------------------------------------------------------------+
| |
| YUM (Yellowdog Updater Modified) |
| +----------------------------------------------------------+ |
| | - Original package manager for RHEL, CentOS, Fedora | |
| | - Written in Python | |
| | - Deprecated in favor of DNF | |
| | - Still available in RHEL 7 | |
| +----------------------------------------------------------+ |
| |
| DNF (Dandified YUM) |
| +----------------------------------------------------------+ |
| | - Drop-in replacement for YUM | |
| | - Written in C (performance improvement) | |
| | - Better dependency resolution | |
| | - Faster and more efficient | |
| | - Default in RHEL 8+, Fedora 22+ | |
| +----------------------------------------------------------+ |
| |
| Compatibility: |
| +----------------------------------------------------------+ |
| | dnf provides yumbase for backward compatibility | |
| | Most yum commands work with dnf | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
DNF Architecture
+------------------------------------------------------------------+
| |
| User Space |
| +-------------------------------------------------------------+ |
| | dnf Command | |
| | (High-level interface for end users) | |
| +-------------------------------------------------------------+ |
| | |
| v |
| +-------------------------------------------------------------+ |
| | libdnf Library | |
| | (Shared library for package management) | |
| +-------------------------------------------------------------+ |
| | |
| v |
| +-------------------------------------------------------------+ |
| | hawkey/libsolv | |
| | (Dependency resolver - written in C) | |
| +-------------------------------------------------------------+ |
| | |
| v |
| +-------------------------------------------------------------+ |
| | RPM Database | |
| | (/var/lib/rpm - package database) | |
| +-------------------------------------------------------------+ |
| |
| Kernel Space |
| +-------------------------------------------------------------+ |
| | File System Operations | |
| | (/var/cache/dnf - package cache) | |
| | (/var/lib/rpm - RPM database) | |
| +-------------------------------------------------------------+ |
| |
+------------------------------------------------------------------+

YUM to DNF Command Mapping
+------------------------------------------------------------------+
| |
| YUM Command | DNF Command | Notes |
| ------------------------|----------------------|---------------|
| yum install | dnf install | Same |
| yum update | dnf upgrade | Preferred |
| yum remove | dnf remove | Same |
| yum search | dnf search | Same |
| yum info | dnf info | Same |
| yum list | dnf list | Same |
| yum repolist | dnf repolist | Same |
| yum group list | dnf group list | Same |
| yum history | dnf history | Enhanced |
| yum localinstall | dnf install | No longer |
| yum deplist | dnf repoquery | Replaced |
| yum provides | dnf provides | Same |
| yum check-update | dnf check-update | Same |
| yum clean all | dnf clean all | Same |
| yum makecache | dnf makecache | Same |
| |
| YUM-Specific | DNF Replacement | |
| ------------------------|----------------------|---------------|
| yum-complete-transaction| dnf-remove-leaves | Removed |
| yum-debug-dump | - | Removed |
| yum-debug-restore | - | Removed |
| yum-groups-manager | - | Removed |
| |
+------------------------------------------------------------------+

RHEL/CentOS Repository Types
+------------------------------------------------------------------+
| |
| Base Repository |
| +----------------------------------------------------------+ |
| | - Core packages from RHEL/CentOS | |
| | - Stability and security patches | |
| | - Examples: coreutils, systemd, httpd | |
| | - BaseOS and AppStream in RHEL 8+ | |
| +----------------------------------------------------------+ |
| |
| Updates Repository |
| +----------------------------------------------------------+ |
| | - Latest bug fixes and security patches | |
| | - Automatically enabled | |
| | - Checked during 'dnf update' | |
| +----------------------------------------------------------+ |
| |
| AppStream Repository (RHEL 8+) |
| +----------------------------------------------------------+ |
| | - Additional applications and runtimes | |
| | - Multiple versions of packages | |
| | - Includes modules and streams | |
| +----------------------------------------------------------+ |
| |
| Extra Packages for Enterprise Linux (EPEL) |
| +----------------------------------------------------------+ |
| | - Extra packages from Fedora | |
| | - Not officially supported | |
| | - Community-maintained | |
| +----------------------------------------------------------+ |
| |
| Third-Party Repositories |
| +----------------------------------------------------------+ |
| | - Docker, Nginx, PostgreSQL, MariaDB, etc. | |
| | - Vendor-provided packages | |
| | - Usually requires GPG key import | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Terminal window
# /etc/yum.repos.d/ directory structure
# Example: nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
priority=1
# Example: docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
# Example: epel.repo (from epel-release package)
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
Terminal window
# List all repositories
dnf repolist
dnf repolist all # including disabled
# List specific repository
dnf repolist enabled
dnf repolist disabled
# Enable repository
sudo dnf config-manager --enable nginx-stable
sudo dnf config-manager --set-enabled nginx-stable
# Disable repository
sudo dnf config-manager --disable nginx-stable
sudo dnf config-manager --set-disabled nginx-stable
# Add new repository
sudo dnf config-manager --add-repo https://example.com/repo.repo
# Set repository options
sudo dnf config-manager --save \
--setopt=nginx-stable.priority=1 \
--setopt=nginx-stable.skip_if_unavailable=true
# View repository configuration
dnf repoquery --repoid=nginx-stable
# Clean repository cache
dnf clean all
dnf clean metadata
# Make cache
dnf makecache
dnf makecache timer # download metadata if older than timer

RHEL 8+ introduced the concept of modules from the AppStream repository, allowing multiple versions of software to be available simultaneously.

AppStream Module Streams
+------------------------------------------------------------------+
| |
| Concept: |
| +----------------------------------------------------------+ |
| | Modules = Collection of RPM packages | |
| | Streams = Different versions of a module | |
| | Profiles = Purpose-specific package sets | |
| +----------------------------------------------------------+ |
| |
| Example: Node.js Module |
| +----------------------------------------------------------+ |
| | nodejs:10 - Node.js 10 (end-of-life) | |
| | nodejs:12 - Node.js 12 (deprecated) | |
| | nodejs:14 - Node.js 14 (supported) | |
| | nodejs:16 - Node.js 16 (supported) | |
| | nodejs:18 - Node.js 18 (default) | |
| | | |
| | Profiles for nodejs:18: | |
| | - common (default) - core runtime | |
| | - development - includes npm, node-gyp | |
| | - minimal - minimal installation | |
| | - s2i - source-to-image support | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Terminal window
# List all available modules
dnf module list
# List specific module
dnf module list nodejs
# Show module information
dnf module info nodejs:18
# Enable module stream
sudo dnf module enable nodejs:18
# Disable module stream
sudo dnf module disable nodejs
# Reset module stream
sudo dnf module reset nodejs
# Install from module
sudo dnf module install nodejs:18
sudo dnf module install nodejs:18/development
# Install default stream
sudo dnf module install nodejs
# Remove module package
sudo dnf module remove nodejs

Package Groups in RHEL
+------------------------------------------------------------------+
| |
| Environment Groups |
| +----------------------------------------------------------+ |
| | - Define entire system environment | |
| | - Examples: "Server with GUI", "Minimal Install" | |
| | - Used during installation | |
| +----------------------------------------------------------+ |
| |
| Task Groups |
| +----------------------------------------------------------+ |
| | - Group packages by functionality | |
| | - Examples: "Development Tools", "System Tools" | |
| +----------------------------------------------------------+ |
| |
| Language Groups |
| +----------------------------------------------------------+ |
| | - Localization packages | |
| | - Examples: "Spanish Support", "Japanese Support" | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Terminal window
# List all groups
dnf group list
# List hidden groups
dnf group list --hidden
# List available groups with IDs
dnf group list --ids
# View group information
dnf group info "Development Tools"
# Install group
sudo dnf group install "Development Tools"
sudo dnf group install @development # using ID
# Install with optional packages
sudo dnf group install "Development Tools" --with-optional
# Remove group
sudo dnf group remove "Development Tools"
# List packages in group
dnf group packages "Development Tools"

DNF Dependency Resolution
+------------------------------------------------------------------+
| |
| hawkey/libsolv Algorithm: |
| +----------------------------------------------------------+ |
| | 1. Collect all dependencies | |
| | 2. Build dependency graph | |
| | 3. Apply policies (install, update, remove) | |
| | 4. Resolve conflicts | |
| | 5. Create transaction | |
| | 6. Order for installation/removal | |
| +----------------------------------------------------------+ |
| |
| Resolution Policies: |
| +----------------------------------------------------------+ |
| | best - Use highest version (default) | |
| | all - Resolve for all | |
| | install - Only for installation | |
| +----------------------------------------------------------+ |
| |
| Conflict Resolution: |
| +----------------------------------------------------------+ |
| | DNF automatically resolves most conflicts | |
| | For manual resolution, use 'dnf remove' first | |
| | Use '--best' to force latest versions | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Terminal window
# Find package providing file
dnf provides /etc/nginx/nginx.conf
dnf provides nginx
# List package dependencies
dnf repoquery --requires nginx
# List packages that depend on package
dnf repoquery --alleviates --requires nginx
dnf rdepends nginx
# Check dependencies before install (dry run)
dnf repoquery --requires --resolve nginx
dnf repoquery --alldeps nginx
# Check for broken dependencies
dnf check
# List package dependencies recursively
dnf repoquery --requires --resolve nginx

Terminal window
# Query installed packages
rpm -qa # all
rpm -qa | grep nginx # specific
rpm -qi nginx # info
# Query package files
rpm -ql nginx # list files
rpm -qc nginx # config files
rpm -qd nginx # doc files
# Query package dependencies
rpm -qR nginx # requires
rpm -q --whatrequires nginx # required by
# Verify package
rpm -V nginx # verify
rpm -Va # verify all
# Install RPM (doesn't resolve dependencies)
sudo rpm -ivh package.rpm
# Upgrade RPM (removes old version)
sudo rpm -Uvh package.rpm
# Freshen RPM (only if older exists)
sudo rpm -Fvh package.rpm
# Uninstall
sudo rpm -e package-name
# Query database
rpm -q --last # by install time
rpm -q --changelog nginx # changelog
rpm -qf /path/to/file # what owns file

Terminal window
# List all transactions
dnf history
dnf history list
# Show specific transaction
dnf history info 15
dnf history info last
# Undo transaction (revert changes)
sudo dnf history undo 15
sudo dnf history undo last
# Rollback to state before transaction
sudo dnf history rollback 15
# Repeat last transaction
sudo dnf history repeat
# New in DNF: User packages and groups
dnf history userinstalled
# History statistics
dnf history stats

Terminal window
# Install DNF plugins
sudo dnf install dnf-plugins-core
sudo dnf install dnf-plugins-extras
# Common plugins:
# dnf-plugins-core: (included by default)
# - config-manager
# - copr
# - debug
# - download
# - groups-manager
# - needs-restarting
# - plugin-pkg
# - repoclosure
# - repodiff
# - repograph
# - repomanage
# - reposync
# Enable/disable plugin
dnf --disablerepo=* install package
dnf -x package install other-package
# Check which plugins are running
dnf repolist -v | grep "From repo"

DNF Configuration Hierarchy
+------------------------------------------------------------------+
| |
| /etc/dnf/dnf.conf |
| +----------------------------------------------------------+ |
| | Main configuration file | |
| +----------------------------------------------------------+ |
| |
| /etc/dnf/plugins/ |
| +----------------------------------------------------------+ |
| | Plugin-specific configuration | |
| +----------------------------------------------------------+ |
| |
| /etc/yum.repos.d/*.repo |
| +----------------------------------------------------------+ |
| | Repository configuration | |
| +----------------------------------------------------------+ |
| |
| ~/.config/dnf/dnf.conf |
| +----------------------------------------------------------+ |
| | User-specific overrides | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
/etc/dnf/dnf.conf
[main]
# Base settings
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
# Performance
fastestmirror=True
max_parellel_downloads=10
timeout=30
# Updates
autocheck=True
update_installed=True
# Cleaning
clean_requirements_on_remove=True
remove_leaves=True
# Notifications
notify=False
# Logging
logdir=/var/log/dnf
errorlevel=0
debuglevel=2
# Exclude packages
exclude=kernel*,centos*
# Include packages (for security policies)
# includepkgs=package1,package2

/etc/dnf/automatic.conf
# Install
sudo dnf install dnf-automatic
[commands]
# upgrade_type = default (all) or security
upgrade_type = security
random_sleep = 60
# download_transactions = daemon/systemd
download_transactions = systemd
[emitters]
# emit_via = email/stdio/none
emit_via = email
email_from = dnf@example.com
email_to = admin@example.com
email_host = localhost
[email]
# SMTP settings if needed
[base]
# base settings from dnf.conf also apply
# Enable and start timer
sudo systemctl enable --now dnf-automatic.timer
sudo systemctl enable --now dnf-automatic.service
# Check status
systemctl status dnf-automatic.timer

DNF Troubleshooting Guide
+------------------------------------------------------------------+
| |
| Issue: Repository metadata expired |
| +----------------------------------------------------------+ |
| | Solution: dnf clean metadata && dnf makecache | |
| +----------------------------------------------------------+ |
| |
| Issue: Package conflicts |
| +----------------------------------------------------------+ |
| | Solution: dnf remove conflicting && dnf install | |
| | Or: dnf upgrade --all | |
| +----------------------------------------------------------+ |
| |
| Issue: Missing dependencies |
| +----------------------------------------------------------+ |
| | Solution: dnf repoquery --requires --resolve package | |
| +----------------------------------------------------------+ |
| |
| Issue: GPG key errors |
| +----------------------------------------------------------+ |
| | Solution: rpm --import /path/to/gpg-key | |
| +----------------------------------------------------------+ |
| |
| Issue: Held back packages |
| +----------------------------------------------------------+ |
| | Solution: dnf upgrade --best | |
| +----------------------------------------------------------+ |
| |
| Issue: "Nothing to do" despite updates |
| +----------------------------------------------------------+ |
| | Solution: dnf list updates && dnf upgrade | |
| +----------------------------------------------------------+ |
| |
+------------------------------------------------------------------+
Terminal window
# Clean all caches
sudo dnf clean all
sudo rm -rf /var/cache/dnf
# Rebuild database
sudo rpm --rebuilddb
# Check broken dependencies
sudo dnf check
# Remove leaves (unused dependencies)
sudo dnf remove-leaves
# List unneeded dependencies
dnf autoremove
# Fix missing dependencies
sudo dnf install --allowerasing package
# Verify package
rpm -V package
# Force reinstall
sudo dnf reinstall package
# Downgrade package
sudo dnf downgrade package

Important

  1. DNF vs YUM: DNF is modern replacement, most commands are compatible
  2. AppStream: RHEL 8+ uses modules for multiple package versions
  3. Repository priority: Use priority in repo file to prefer specific repos
  4. Groups: Use dnf group for installing related packages
  5. History: DNF tracks all transactions, can undo/rollback
  6. Modules: Use dnf module for enabling specific versions
  7. Configuration: Main config in /etc/dnf/dnf.conf
  8. Plugins: DNF is extensible via plugins
  9. Automatic updates: Use dnf-automatic for automated patching
  10. Dependencies: Use dnf repoquery to check dependencies

In this chapter, you learned:

  • ✅ DNF vs YUM architecture and differences
  • ✅ Repository management and configuration
  • ✅ AppStream modules and streams
  • ✅ Package groups
  • ✅ Dependency resolution with hawkey/libsolv
  • ✅ RPM direct commands
  • ✅ Transaction history (undo/rollback)
  • ✅ DNF plugins and configuration
  • ✅ Automatic updates with dnf-automatic
  • ✅ Troubleshooting common issues

Chapter 29: Compiling from Source


Last Updated: February 2026