29.2 yum vs dnf: The Transition and Feature Differences
Alright, let’s talk about the great YUM-to-DNF shift. You remember YUM, right? The Yellowdog Updater, Modified. It was the workhorse of package management on RHEL, CentOS, and Fedora for over a decade. It got the job done, but let’s be honest: by the end, it was a bit like your favorite old couch—comfortable and familiar, but sagging in places, patched with duct tape, and occasionally smelling a bit funky. Its API was a mess, its performance was… leisurely, and its dependency resolution, while mostly correct, wasn’t exactly a marvel of algorithmic efficiency.
Enter DNF, the Dandified YUM. It’s not a rewrite from scratch; that would be insane. Instead, it’s a massive overhaul that replaces YUM’s clunky internals with the far more sophisticated and well-tested libsolv library, which was originally developed for OpenSUSE’s Zypper. This is the key thing to understand: DNF is what YUM always wanted to be when it grew up. The command-line interface is deliberately very similar to ease the transition, but under the hood, it’s a completely different, far more robust beast.
Why the Switch Was Non-Negotiable
The core reason boils down to one word: sustainability. The original codebase for YUM was a sprawling Python script that had evolved organically for years. Maintaining it, adding new features, and fixing its deep-seated bugs became a nightmare. The developers were essentially trying to give a 1998 Honda Civic the performance of a Tesla by bolting on parts. DNF, using libsolv (which is written in C), provides a dramatically faster and more reliable dependency resolver. It handles complex transactions with more grace and gives us much better output during operations. It also has a proper, clean API, which means tools like Ansible can integrate with it more reliably.
The Command-Line Similarities (And The Gotchas)
For most day-to-day operations, you can just mentally substitute yum for dnf and you’re golden. Seriously.
# The Old Faithful (YUM)
sudo yum install httpd
sudo yum update
sudo yum remove httpd
# The New Hotness (DNF)
sudo dnf install httpd
sudo dnf update
sudo dnf remove httpd
See? No big deal. The dnf commands are even aliased to yum on most systems that have transitioned, so your old muscle memory and scripts might keep working, but you should stop relying on that crutch. The aliasing is there for convenience, not as a permanent feature.
Now, for the minor differences that will bite you if you’re not paying attention. The output format is cleaner and more informative. More importantly, the update behavior has a subtle but critical improvement: dnf update, unlike its predecessor, does not update the dnf package itself by default. You have to explicitly say sudo dnf update dnf. This is a sane default that prevents a running package manager from trying to update itself mid-transaction, which is about as safe as performing engine surgery while driving down the highway.
Where DNF Just Plain Outclasses YUM
This is where the “dandified” part earns its name.
1. Performance: The difference isn’t subtle. dnf is significantly faster, especially when resolving dependencies for large transactions or dealing with many repositories. libsolv is a beast.
2. Better Dependency Resolution: It’s not just faster; it’s smarter. It provides better error messages when things go wrong and can handle more complex scenarios.
3. A Modern Python API: This is huge for sysadmins who automate things. The dnf Python API is actually usable and well-documented. Trying to use the YUM API was like performing a séance to commune with a grumpy and incomprehensible spirit.
4. Cleaner History and Rollback: The history command is vastly improved.
sudo dnf history list
sudo dnf history info 15 # Get details on transaction 15
sudo dnf history undo 15 # The magic trick. Attempts to reverse transaction 15.
The undo command is a lifesaver. It tries to compute the inverse operation of a past transaction and apply it. It’s not magic (it can’t undo configuration file changes you made by hand, for instance), but for pure package operations, it’s brilliant.
Best Practices and The One Big Pitfall
First, the pitfall: Your old third-party repositories. This is the number one cause of post-transition pain. Many older repositories (I’m looking at you, various random RPMForge clones) provided a yum-priorities plugin to manage conflict resolution. DNF handles this natively with a better concept called module_hotfixes and just generally smarter resolution. However, some repos never updated their metadata to be cleanly consumed by libsolv. If you see dependency resolution errors after switching to dnf, disable all your third-party repos and add them back one by one. The offending repo will quickly identify itself.
The best practice? Embrace the change. Stop using yum even if the alias is there. Start using the new features. Use dnf search --showduplicates <packagename> to see all available versions. Use dnf list --installed to see what’s on your system. Get comfortable with dnf history; it will save your bacon one day.
The transition from YUM to DNF wasn’t an arbitrary change. It was a necessary engineering evolution. YUM served us well, but it was time to retire the old warhorse. DNF is the competent, faster, and more reliable successor we needed. The designers, for once, made a choice that was unquestionably correct.