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”28.1 Understanding DNF and YUM
Section titled “28.1 Understanding DNF and YUM”What is DNF?
Section titled “What is DNF?”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 | || +----------------------------------------------------------+ || |+------------------------------------------------------------------+Architecture
Section titled “Architecture” 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) | || +-------------------------------------------------------------+ || |+------------------------------------------------------------------+28.2 YUM/DNF Commands Comparison
Section titled “28.2 YUM/DNF Commands Comparison”Command Mapping
Section titled “Command Mapping” 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 || |+------------------------------------------------------------------+28.3 Repository Management
Section titled “28.3 Repository Management”Repository Types
Section titled “Repository Types” 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 | || +----------------------------------------------------------+ || |+------------------------------------------------------------------+Repository Configuration Files
Section titled “Repository Configuration Files”# /etc/yum.repos.d/ directory structure
# Example: nginx.repo[nginx-stable]name=nginx stable repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/gpgcheck=1enabled=1gpgkey=https://nginx.org/keys/nginx_signing.keymodule_hotfixes=truepriority=1
# Example: docker-ce.repo[docker-ce-stable]name=Docker CE Stable - $basearchbaseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stableenabled=1gpgcheck=1gpgkey=https://download.docker.com/linux/centos/gpg
# Example: epel.repo (from epel-release package)[epel]name=Extra Packages for Enterprise Linux $releasever - $basearchenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releaseverManaging Repositories
Section titled “Managing Repositories”# List all repositoriesdnf repolistdnf repolist all # including disabled
# List specific repositorydnf repolist enableddnf repolist disabled
# Enable repositorysudo dnf config-manager --enable nginx-stablesudo dnf config-manager --set-enabled nginx-stable
# Disable repositorysudo dnf config-manager --disable nginx-stablesudo dnf config-manager --set-disabled nginx-stable
# Add new repositorysudo dnf config-manager --add-repo https://example.com/repo.repo
# Set repository optionssudo dnf config-manager --save \ --setopt=nginx-stable.priority=1 \ --setopt=nginx-stable.skip_if_unavailable=true
# View repository configurationdnf repoquery --repoid=nginx-stable
# Clean repository cachednf clean alldnf clean metadata
# Make cachednf makecachednf makecache timer # download metadata if older than timer28.4 Module Streams (AppStream)
Section titled “28.4 Module Streams (AppStream)”Understanding Modules
Section titled “Understanding Modules”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 | || +----------------------------------------------------------+ || |+------------------------------------------------------------------+Module Commands
Section titled “Module Commands”# List all available modulesdnf module list
# List specific modulednf module list nodejs
# Show module informationdnf module info nodejs:18
# Enable module streamsudo dnf module enable nodejs:18
# Disable module streamsudo dnf module disable nodejs
# Reset module streamsudo dnf module reset nodejs
# Install from modulesudo dnf module install nodejs:18sudo dnf module install nodejs:18/development
# Install default streamsudo dnf module install nodejs
# Remove module packagesudo dnf module remove nodejs28.5 Package Groups
Section titled “28.5 Package Groups”Group Types
Section titled “Group Types” 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" | || +----------------------------------------------------------+ || |+------------------------------------------------------------------+Group Commands
Section titled “Group Commands”# List all groupsdnf group list
# List hidden groupsdnf group list --hidden
# List available groups with IDsdnf group list --ids
# View group informationdnf group info "Development Tools"
# Install groupsudo dnf group install "Development Tools"sudo dnf group install @development # using ID
# Install with optional packagessudo dnf group install "Development Tools" --with-optional
# Remove groupsudo dnf group remove "Development Tools"
# List packages in groupdnf group packages "Development Tools"28.6 Package Dependencies
Section titled “28.6 Package Dependencies”Dependency Resolution
Section titled “Dependency Resolution” 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 | || +----------------------------------------------------------+ || |+------------------------------------------------------------------+Dependency Commands
Section titled “Dependency Commands”# Find package providing filednf provides /etc/nginx/nginx.confdnf provides nginx
# List package dependenciesdnf repoquery --requires nginx
# List packages that depend on packagednf repoquery --alleviates --requires nginxdnf rdepends nginx
# Check dependencies before install (dry run)dnf repoquery --requires --resolve nginxdnf repoquery --alldeps nginx
# Check for broken dependenciesdnf check
# List package dependencies recursivelydnf repoquery --requires --resolve nginx28.7 RPM Commands
Section titled “28.7 RPM Commands”Direct RPM Management
Section titled “Direct RPM Management”# Query installed packagesrpm -qa # allrpm -qa | grep nginx # specificrpm -qi nginx # info
# Query package filesrpm -ql nginx # list filesrpm -qc nginx # config filesrpm -qd nginx # doc files
# Query package dependenciesrpm -qR nginx # requiresrpm -q --whatrequires nginx # required by
# Verify packagerpm -V nginx # verifyrpm -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
# Uninstallsudo rpm -e package-name
# Query databaserpm -q --last # by install timerpm -q --changelog nginx # changelogrpm -qf /path/to/file # what owns file28.8 Transaction History
Section titled “28.8 Transaction History”Using History
Section titled “Using History”# List all transactionsdnf historydnf history list
# Show specific transactiondnf history info 15dnf history info last
# Undo transaction (revert changes)sudo dnf history undo 15sudo dnf history undo last
# Rollback to state before transactionsudo dnf history rollback 15
# Repeat last transactionsudo dnf history repeat
# New in DNF: User packages and groupsdnf history userinstalled
# History statisticsdnf history stats28.9 Plugin Management
Section titled “28.9 Plugin Management”DNF Plugins
Section titled “DNF Plugins”# Install DNF pluginssudo dnf install dnf-plugins-coresudo 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 plugindnf --disablerepo=* install packagednf -x package install other-package
# Check which plugins are runningdnf repolist -v | grep "From repo"28.10 DNF Configuration
Section titled “28.10 DNF Configuration”Configuration Files
Section titled “Configuration Files” 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 | || +----------------------------------------------------------+ || |+------------------------------------------------------------------+Common Configuration Options
Section titled “Common Configuration Options”[main]# Base settingsgpgcheck=1installonly_limit=3clean_requirements_on_remove=Truebest=Trueskip_if_unavailable=False
# Performancefastestmirror=Truemax_parellel_downloads=10timeout=30
# Updatesautocheck=Trueupdate_installed=True
# Cleaningclean_requirements_on_remove=Trueremove_leaves=True
# Notificationsnotify=False
# Logginglogdir=/var/log/dnferrorlevel=0debuglevel=2
# Exclude packagesexclude=kernel*,centos*
# Include packages (for security policies)# includepkgs=package1,package228.11 Automatic Updates
Section titled “28.11 Automatic Updates”dnf-automatic
Section titled “dnf-automatic”# Installsudo dnf install dnf-automatic
[commands]# upgrade_type = default (all) or securityupgrade_type = securityrandom_sleep = 60# download_transactions = daemon/systemddownload_transactions = systemd
[emitters]# emit_via = email/stdio/noneemit_via = emailemail_from = dnf@example.comemail_to = admin@example.comemail_host = localhost
[email]# SMTP settings if needed
[base]# base settings from dnf.conf also apply
# Enable and start timersudo systemctl enable --now dnf-automatic.timersudo systemctl enable --now dnf-automatic.service
# Check statussystemctl status dnf-automatic.timer28.12 Troubleshooting
Section titled “28.12 Troubleshooting”Common Issues
Section titled “Common Issues” 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 | || +----------------------------------------------------------+ || |+------------------------------------------------------------------+Recovery Commands
Section titled “Recovery Commands”# Clean all cachessudo dnf clean allsudo rm -rf /var/cache/dnf
# Rebuild databasesudo rpm --rebuilddb
# Check broken dependenciessudo dnf check
# Remove leaves (unused dependencies)sudo dnf remove-leaves
# List unneeded dependenciesdnf autoremove
# Fix missing dependenciessudo dnf install --allowerasing package
# Verify packagerpm -V package
# Force reinstallsudo dnf reinstall package
# Downgrade packagesudo dnf downgrade package28.13 Exam Tips
Section titled “28.13 Exam Tips”- DNF vs YUM: DNF is modern replacement, most commands are compatible
- AppStream: RHEL 8+ uses modules for multiple package versions
- Repository priority: Use priority in repo file to prefer specific repos
- Groups: Use
dnf groupfor installing related packages - History: DNF tracks all transactions, can undo/rollback
- Modules: Use
dnf modulefor enabling specific versions - Configuration: Main config in
/etc/dnf/dnf.conf - Plugins: DNF is extensible via plugins
- Automatic updates: Use
dnf-automaticfor automated patching - Dependencies: Use
dnf repoqueryto check dependencies
Summary
Section titled “Summary”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
Next Chapter
Section titled “Next Chapter”Chapter 29: Compiling from Source
Last Updated: February 2026