thelinuxvault guide

Diving into DNF: The Modern Package Manager for Fedora

If you’ve recently installed Fedora Linux or are considering making the switch, one tool will quickly become indispensable: **DNF** (Dandified YUM). As Fedora’s default package manager, DNF is the backbone of how you install, update, remove, and manage software on your system. Whether you’re a new user setting up your first Fedora desktop or a seasoned sysadmin maintaining servers, understanding DNF is key to mastering Fedora’s ecosystem. In this blog, we’ll explore DNF from the ground up—what it is, why it matters, its core features, and how to use it effectively. By the end, you’ll be equipped to handle everything from basic software installation to advanced package management tasks.

Table of Contents

  1. What is DNF?
  2. Key Features of DNF
  3. Core DNF Commands
  4. Advanced DNF Usage
  5. DNF Plugins: Extending Functionality
  6. Configuring DNF
  7. DNF vs. Other Package Managers
  8. Troubleshooting Common DNF Issues
  9. Conclusion
  10. 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.

CommandPurposeExample
dnf check-updateList available updatessudo dnf check-update
dnf updateUpdate all installed packagessudo dnf update
dnf install <package>Install a packagesudo dnf install firefox
dnf remove <package>Uninstall a packagesudo dnf remove thunderbird
dnf search <term>Search for packages by name/descriptiondnf search "text editor"
dnf info <package>Show details about a packagednf info neovim
dnf list installedList all installed packagesdnf list installed
dnf list availableList all available packages in reposdnf list available 'python3*'
dnf clean allClear cached packages and metadatasudo dnf clean all
dnf autoremoveRemove unused dependenciessudo 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 -y to 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 htop installs the htop system monitor and any required libraries.

  • Search for Packages: dnf search <keyword>
    Use quotes for multi-word searches: dnf search "image viewer" returns packages like gthumb or eog.

  • Remove a Package: sudo dnf remove <package-name>
    This uninstalls the package but leaves behind unused dependencies. Use autoremove afterward 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 all clears 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-copr  
  • download: Download a package (without installing) with dnf 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?

FeatureDNF (Fedora/RHEL)APT (Debian/Ubuntu)Pacman (Arch)Zypper (openSUSE)
Package FormatRPMDEBTAR.XZ (Pacman)RPM
Dependency Solverlibsolvlibapt-pkgCustomlibsolv
SpeedFastFastVery FastFast
Transaction HistoryYes (undo/redo)Limited (via aptitude)Yes (with pacman -U)Yes
ModularityNative (Fedora)NoAUR-basedYes (Modules)
Plugin EcosystemRichModerateMinimalRich

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!

References