Home AlmaLinux What is the Difference Between DNF and YUM Commands?

What is the Difference Between DNF and YUM Commands?

Brief: This article guide explains the nature and differences between the Yum package manager and the DNF package manager in Fedora and Red Hat-based Linux distributions.

The first step to being a Linux user is choosing a preferred Linux operating system distribution. A key identifier in each Linux distribution is the package manager used to perform operating system tasks like installing, updating, upgrading, and removing packages or software collections.

Some popular package managers include APT (Advanced Packaging Tool) for Debian and Ubuntu distributions, ZYPPER for SUSE Linux Enterprise, and PACMAN for Arch Linux distribution.

When it comes to red hat-based Linux distributions like RHEL, Rocky Linux, and AlmaLinux, users are able to interact with both DNF and YUM package managers to accomplish common operating system tasks.

However, we need to air out the differences between these two package managers and why they are allowed to co-exist with one another.

Differences Between YUM and DNF Package Managers

Both YUM (Yellowdog Updater, Modified) and DNF (Dandified YUM) borrow the RPM (Red Hat Package Manager) package format to perform package management tasks like installing, updating, and removing packages.

The onset of Fedora 18 saw the introduction of DNF as a replacement for YUM. DNF came into the picture because of transparent YUM limitations that warranted a modern and feature-rich alternative.

YUM’s Limitations in Comparison to DNF

Some of YUM’s limitations in comparison to DNF include:

  • Performance and dependency resolution – DNF resolves dependency issues much faster than YUM.
  • Package metadata – With DNF, users can use the package manager’s database to store additional package info (package metadata). This feature is absent in YUM.
  • Transaction rollback – With DNF, a user is able to undo changes implemented by a package manager (rollback transactions). This feature is unavailable in YUM.
  • Database format – Compared to YUM, DNF’s database format is faster and more efficient.
  • Handling multiple package versions – DNF supports the installation of multiple versions of packages whereas YUM does not support this functionality.

We can therefore summarize DNF’s improvement to YUM’s limitation with the following bullet points:

  • Support for rollback transactions.
  • Support for package metadata.
  • Better performance and dependency resolution.
  • New, faster, and more efficient database format.
  • Better multiple version handling mechanisms for packages.

DNF vs Yum – Package Management

When it comes to basic package management routines, these two commands adhere to the same syntax as demonstrated below:

Installing a Package
$ sudo yum install package_name
$ sudo dnf install package_name
Update Installed Packages
$ sudo yum update
$ sudo dnf update
Removing a Package
$ sudo yum remove package_name
$ sudo dnf remove package_name
Searching a Package
$ yum search package_name
$ dnf search package_name
Displaying Package Info
$ yum info package_name
$ dnf info package_name 

On the other hand, the following DNF commands are not equivalent to YUM:

Rolling Back Transactions with DNF

Both DNF and YUM commands can be used to display a list of already executed transactions (command-line history). However, only DNF is capable of undoing a command execution from the history list based on the command/transaction ID.

$ dnf history
$ sudo dnf history undo <transaction_id>
DNF Rolling Back Transactions
DNF Rolling Back Transactions

Based on the above screen capture, the command ‘update‘ for system update is identified by transaction ID ‘4‘ hence this transaction is rolled back by the command:

$ sudo dnf history undo 4
Rolling Back Transactions with YUM

It is not the same case with YUM. The following screenshot confirms that the transaction rollback feature is not supported by YUM.

$ yum history
$ sudo yum history undo <transaction_id>

Here will try to roll back transaction ID 2 for installing the curl package and end up with the error “cannot find rpm nevra” which suggests that the curl package does not exist when it actually does.

$ curl -V

Rolling Back Yum Transactions
Rolling Back Yum Transactions
Installing Multiple Versions of a Package

To install multiple versions of a package named foo, we would run:

$ sudo dnf install foo-1.0 foo-2.0
Displaying Package Dependencies
$ dnf repoquery --requires tree
$ yum deplist tree
Check Package Dependencies
Check Package Dependencies

Overall, DNF is an up-to-date YUM version with rich features and a better performance spectrum. These key differences confirm that DNF is evolving and is a much more preferred package manager in comparison to YUM.

Also, newer versions of RPM-based Linux distributions are already doing away with (deprecating) the usage of the YUM package manager. It is therefore recommended to start adapting to the feature-rich nature of DNF for future package management pursuits.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

2 thoughts on “What is the Difference Between DNF and YUM Commands?”

  1. The yum command is just a symlink to dnf command now. So there is absolutely no difference between the two commands or how you use them.

    Reply
    • @Michale,

      You are absolutely correct, but there are a few limitations between yum and dnf which are discussed in this article…

      Reply

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.