Table of Contents
- What is DNF?
- Key Features of DNF
- Core DNF Commands
- Advanced DNF Usage
- DNF Plugins: Extending Functionality
- Configuring DNF
- DNF vs. Other Package Managers
- Troubleshooting Common DNF Issues
- Conclusion
- References
What is DNF?
DNF (Dandified YUM) is a modern, high-performance package manager for RPM-based Linux distributions like Fedora, Red Hat Enterprise Linux (RHEL), CentOS Stream, and Oracle Linux. It succeeded YUM (Yellowdog Updater, Modified) as the default package manager in Fedora 22 (released in 2015) and has since become the standard for managing RPM packages in these ecosystems.
A Brief History
YUM, introduced in 2003, revolutionized RPM package management by automating dependency resolution. However, over time, YUM faced criticism for slow performance, inefficient memory usage, and limited flexibility. DNF was developed to address these pain points: it uses libsolv (a fast dependency resolver) and is written in Python, making it more maintainable and extensible than YUM. Today, DNF is faster, more reliable, and packed with features that simplify software management.
Key Features of DNF
DNF isn’t just a “better YUM”—it’s a complete reimagining of RPM package management. Here are its standout features:
1. Lightning-Fast Dependency Resolution
DNF uses libsolv, an open-source dependency solver developed by SUSE, to resolve package dependencies. Libsolv is optimized for speed and accuracy, even with complex dependency trees (e.g., installing development tools or desktop environments). This makes DNF significantly faster than YUM, especially when dealing with large numbers of packages.
2. Transaction History & Rollbacks
DNF keeps a detailed log of all package transactions (installs, updates, removals). You can view this history with dnf history and even undo/redo transactions (e.g., dnf history undo 5 to revert the 5th transaction). This is a lifesaver if an update breaks your system!
3. Modularity Support
Fedora introduced Modularity to manage multiple versions of software (e.g., Python 3.8 vs. 3.9) on the same system. DNF natively supports modules, allowing you to install, enable, or switch between module streams (e.g., dnf module install python39).
4. Parallel Downloads
DNF can download multiple packages simultaneously, drastically reducing update/install times. You can configure the number of parallel downloads via the max_parallel_downloads setting in dnf.conf.
5. Plugin Ecosystem
DNF’s plugin system extends its functionality. Plugins like dnf-automatic (for automatic updates), copr (to access community repos), and langpacks (for language support) make DNF highly customizable.
6. Improved Memory Usage
Unlike YUM, which often struggled with memory constraints on large operations, DNF is optimized to use memory efficiently, even when updating hundreds of packages.
Core DNF Commands
Let’s dive into the most essential DNF commands you’ll use daily. All commands requiring system changes (install, update, remove) need sudo.
| Command | Purpose | Example |
|---|---|---|
dnf check-update | List available updates | sudo dnf check-update |
dnf update | Update all installed packages | sudo dnf update |
dnf install <package> | Install a package | sudo dnf install firefox |
dnf remove <package> | Uninstall a package | sudo dnf remove thunderbird |
dnf search <term> | Search for packages by name/description | dnf search "text editor" |
dnf info <package> | Show details about a package | dnf info neovim |
dnf list installed | List all installed packages | dnf list installed |
dnf list available | List all available packages in repos | dnf list available 'python3*' |
dnf clean all | Clear cached packages and metadata | sudo dnf clean all |
dnf autoremove | Remove unused dependencies | sudo dnf autoremove |
Breakdown of Key Commands
-
Update Your System:
sudo dnf update
This fetches the latest package metadata and updates all installed packages to their newest versions. Add-yto auto-confirm (e.g.,sudo dnf update -y). -
Install a Package:
sudo dnf install <package-name>
DNF automatically resolves and installs dependencies. For example,sudo dnf install htopinstalls thehtopsystem monitor and any required libraries. -
Search for Packages:
dnf search <keyword>
Use quotes for multi-word searches:dnf search "image viewer"returns packages likegthumboreog. -
Remove a Package:
sudo dnf remove <package-name>
This uninstalls the package but leaves behind unused dependencies. Useautoremoveafterward to clean those up. -
Clean Up Cached Files:
sudo dnf clean all
DNF caches downloaded packages and metadata to speed up future operations. Over time, this cache can grow—clean allclears it to free space.
Advanced DNF Usage
Once you’re comfortable with the basics, explore these advanced workflows:
Group Installs
Fedora groups related packages into “package groups” (e.g., “Development Tools” or “KDE Plasma Desktop”). Install an entire group with:
sudo dnf groupinstall "Development Tools"
List all groups with dnf group list, and view group contents with dnf group info "Development Tools".
Reinstall or Downgrade Packages
- Reinstall: Fix corrupted packages with
sudo dnf reinstall <package>(e.g.,sudo dnf reinstall firefox). - Downgrade: Roll back to an older version with
sudo dnf downgrade <package>(requires an older version in repos).
Manage Repositories
DNF pulls packages from repositories (repos). List enabled repos with:
dnf repolist enabled
Enable/disable repos temporarily with --enablerepo or --disablerepo:
sudo dnf install vlc --enablerepo=rpmfusion-free-updates
Transaction History
View your package management history with dnf history:
dnf history
# Output: ID | Command line | Date and time | Action(s) | Altered
# Example: 12 | install htop | 2024-03-15 14:30 | Install | 1
Undo a transaction (e.g., ID 12) with:
sudo dnf history undo 12
DNF Plugins: Extending Functionality
Plugins add powerful features to DNF. Here are the most useful ones:
1. dnf-automatic (Automatic Updates)
Install with sudo dnf install dnf-automatic, then configure auto-updates in /etc/dnf/automatic.conf. Set apply_updates = yes to automatically install updates.
2. dnf-plugins-core (Essential Plugins)
Includes commands like:
copr: Access community repos from Fedora COPR. Example:sudo dnf copr enable user/repo sudo dnf install package-from-coprdownload: Download a package (without installing) withdnf download <package>.
3. langpacks (Language Support)
Install language packs for your locale:
sudo dnf install langpacks-fr # Installs French language support
4. debuginfo-install (Debug Packages)
For developers, install debug symbols for a package:
sudo dnf debuginfo-install firefox
Configuring DNF
Customize DNF’s behavior via configuration files and repo settings.
Main Configuration File: dnf.conf
Located at /etc/dnf/dnf.conf, this file controls global settings. Common options:
[main]
gpgcheck=1 # Verify package signatures
installonly_limit=3 # Keep 3 old kernel versions
clean_requirements_on_remove=1 # Remove unused deps when uninstalling
max_parallel_downloads=5 # Download 5 packages at once
fastestmirror=True # Use the fastest repo mirror
keepcache=0 # Delete packages after installation (0=disable, 1=enable)
Repository Configuration
Repos are defined in .repo files under /etc/yum.repos.d/. Fedora ships with default repos (e.g., fedora.repo, updates.repo). To add third-party repos (e.g., RPM Fusion), install their repo files:
# Enable RPM Fusion Free (open-source software)
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
DNF vs. Other Package Managers
How does DNF stack up against alternatives?
| Feature | DNF (Fedora/RHEL) | APT (Debian/Ubuntu) | Pacman (Arch) | Zypper (openSUSE) |
|---|---|---|---|---|
| Package Format | RPM | DEB | TAR.XZ (Pacman) | RPM |
| Dependency Solver | libsolv | libapt-pkg | Custom | libsolv |
| Speed | Fast | Fast | Very Fast | Fast |
| Transaction History | Yes (undo/redo) | Limited (via aptitude) | Yes (with pacman -U) | Yes |
| Modularity | Native (Fedora) | No | AUR-based | Yes (Modules) |
| Plugin Ecosystem | Rich | Moderate | Minimal | Rich |
DNF’s Edge: Best for RPM-based distros, robust dependency handling, and deep integration with Fedora’s modularity and tooling.
Troubleshooting Common DNF Issues
GPG Key Errors
If you see “GPG key retrieval failed,” import the missing key:
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$(rpm -E %fedora)-x86_64
Broken Dependencies
Run sudo dnf check to detect issues. Fix with:
sudo dnf clean all
sudo dnf update --skip-broken
Slow Downloads
Enable fastestmirror=True in dnf.conf, or manually select a faster repo in /etc/yum.repos.d/.
Repo Not Found
Ensure the repo is enabled: sudo dnf repolist enabled. If missing, reinstall the repo file (e.g., RPM Fusion).
Conclusion
DNF is more than just a package manager—it’s the gateway to Fedora’s vast software ecosystem. Its speed, reliability, and feature set make it a standout tool for both casual users and system administrators. Whether you’re installing a single app or managing a server fleet, mastering DNF will streamline your Linux experience.
So go ahead: fire up your terminal, run sudo dnf update, and explore all that Fedora has to offer—powered by DNF!