DNF Vs YUM [How Both Are Different]

DNF and YUM are the package manager tools that are used for the RedHat-based Linux distribution. Both of the packages are used to manage the system efficiently. For a better understanding of these two packages, you have to understand the differences. This article explains dnf vs yum in depth. This will help you to distinguish between these two popular package managers.

What is YUM?

In RedHat-based Linux distribution, a primary package for managing software packages is YUM which refers to Yellowdog Updater Modifier. It is a default package manager in many RPM-based distributions including CentOS, RHEL, and Oracle Linux. It facilitates the installation, updating, removal, and management of dependencies on a system. It also simplifies management by resolving dependencies automatically.

What is DNF?

DNF the short form of Dandified YUM, is the successor of YUM. This package manager is used in RPM-based Linux distribution. As it is the modern version of Yum, it shows better performance and resolution. DNF is the feature-riched package manager that supports parallel downloading, modular repositories, and enhanced plugin support. It resolves dependencies more efficiently.

DNF vs YUM: Comparisons of Features

Here you can see the comparison of features between dnf and yum below:

Feature Dnf Yum
Package Manager Default package manager in RedHat Linux 8, Fedora, and the later version of RHEL. Default package manager in Red Hat (RHEL 6,7), CentOS (6,7), Oracle Linux(6,7), and older versions of RHEL.
Extensions Various extensions. Python-based extension.
API Is fully documented. Poorly documented compared to dnf.
Kernel package Is not protected. Can delete any package including the running one.
New features Easy to create new features. Difficult to create new features.
Memory Uses less memory while synchronizing metadata. Use excessive memory.
Performance Faster than YUM and better resolution of dependencies. Overall poor.
Bug Reporting Automatic. Did not support.
Line of code C, C++, Python codes of 29k lines. 56k line python codes.
Dependency solver algorithm Improved. Simple.
Dependency update Did not update the installed dependencies. Shows the option to update.
Repository management Without the enabled repository it will continue with available repositories. Yum will stop immediately if the repository is not available.
Parallel downloading Effective parallel downloading. Can not download as effectively as dnf can.
Plugin More integrated with the core. More plugins that increase functionality.
Modular design Yes. No.
Efficient network More efficient. Less efficient.

From the above comparison chart, you can understand it is better to use dnf instead of yum.

Primary Distinction Between YUM and DNF

Besides the many differences in features, some key problems are solved by dnf and make it smarter than yum. Here I have shown the key feature distinction below:

A. API

The API of Yum is not as strongly documented as DNF. Mainly the yum code is simpler compared to dnf. As dnf shows complexity, it also provides efficient performance. For simpler tasks, you can use the Yum package manager.

B. Dependency Resolution

The main purpose of the package managers is to manage the RPM packages and resolve the resolution. Dnf uses libsolv to resolve dependency which is the more modern and advanced algorithm and libsolv is the better code-based algorithm that is written in C, C++, and Python.

On the other hand, Yum uses public API which is not documented to resolve dependency.

C. Performance

DNF uses less memory in comparison to YUM. As many issues with yum are unsolved for that reason, it is replaced by dnf which did not show that type of problem. While processing metadata yum uses excessive memory which slows down the upgrading process.

Why DNF Has Been Built?

There are some problems with yum that make dnf built. The problems are:

  • Excessive memory use.
  • Poor performance.
  • Dependency resolution proceeds slowly.
  • Use poorly documented API for dependency resolution.

On the other, dnf uses libsolv for dependency resolution. Here you can ask why these problems are not resolved in yum. Yum has 56k lines code whereas dnf has 29k lines code which can not be replaced.

Common Useful Commands of DNF and YUM

Here are some useful commands of the package managers which you can use to manage the distribution:

Functions Dnf command Yum command
Install a package dnf install [package name] yum install [package name]
Remove the desired package dnf remove [package name] yum remove [package name]
Update or upgrade a single package dnf update

dnf upgrade [package name]

yum update

yum upgrade [package name]

Search for a package dnf search [package name] yum search [package name]
List of all packages dnf list installed

dnf list available

yum list –installed or yum list installed

yum list –available

Reinstall a package dnf reinstall [package name] yum reinstall [package name]
Clean up the system dnf clean all

dnf autoremove

yum clean all

yum autoremove

Information about the desired package dnf info [package name] yum info [package name]
Display repository list dnf repolist

dnf repolist all

yum repolist

yum repolist all

Downgrade a package dnf downgrade [package name] yum downgrade [package name]

From the command chart, you can see the syntax is quite similar. Moreover, some syntaxes of dnf are simple than yum.

Examples of DNF Package Manager

Below I have shown some command examples that you can use with dnf:

Example 1: How to Install a DNF Package

To install a dnf package in Redhat copy this command. Here I will install httpd, you can choose any package according to your liking.

sudo dnf install httpd
EXPLANATION
  • sudo: Permits administrative privileges.
  • dnf: High-level package manager which is the successor of yum.
  • install: command install the following package.
  • httpd: The package which I want to install.

A package is Installed with dnf

To confirm the installation you have to type Y and then press ENTER.

Confirming Installation press y

Display installation complete

From the image, you can see that dnf completes the installation.

If you want to install a specific version, you can do this with dnf. To do this you can copy this command:

sudo dnf install samba-4.17.5-103.el9_2

Installing a package of specific version with dnf

Here I install this version of this package you can install packages according to your liking.

Example 2: How to Remove a Package With Redhat

To remove a package with RedHat you can copy the command:

sudo dnf remove totem
EXPLANATION
  • remove: Remove the desired package from the repository.
  • totem: The package that I want to remove.

Remove a package totem with dnf

From the image you can see, dnf removes the unused dependencies. Here I remove the totem package, you can remove any other package according to your liking.

Example 3: Search a Package With “dnf”

If you need to find a package with dnf you can locate it by search command. For that, you can use the command:

sudo dnf search httpd
EXPLANATION
  • search: Locate a package in the repository.
  • httpd: The package which I searched for.

Search for httpd with dnf

From the image, I searched the httpd package. You can use any package according to your need.

Example 4: Update Packages in Redhat

When you want to update a package or all the packages you can copy this command in Redhat:

sudo dnf update
EXPLANATION
  • update: Command to make packages up to date.

Update all packages with dnf

Here I update all the available packages with the latest version. From the image, you can see with dnf, the upgrade is also done with the update command.

Confirm download of upgradable packages with dnf

From the image you can see, to confirm the download of the upgraded version, you have to press the Y button. Then you have to press ENTER.

Examples of YUM Package Manager

Below I have given some command examples which you can use with yum:

Example 1: How to Install a YUM Package

To install a yum package in Redhat copy this command. Here I will install Firefox, you can choose any package according to your liking.

sudo yum install firefox
EXPLANATION
  • yum: Primary package management system in Red Hat that provides a high-level front-end command interface.
  • firefox: The package which I want to install.

Install a package firefox with yum

After the installation command, there will be a confirmation question. If you want to skip this confirmation question you can use the -y option in the installation command. Otherwise in this panel press Y and then press ENTER to confirm installation.

Confirming installation with y

Displays installation complete

After completing the installation it displays the ‘complete’ syntax.

Example 2: How to Remove a Package With “yum”

If you want to remove a package with yum you can copy the following command:

sudo yum remove postgresql
EXPLANATION
  • remove: Remove the desired package from the repository.
  • postgresql: The package that I want to remove.

Remove a package with yum

In the command I use PostgreSQL package you can choose your desired package.

Example 3: Search a Package Using “yum”

If you want to search a package in the repository you can use the search command to locate the package. Here is the command:

sudo yum search postgresql
EXPLANATION
  • search: Locate a package in the repository.
  • postgresql: The package which I searched for.

Search for a package with yum

From the image, you can see I use the PostgreSQL package. You can use any package according to your liking.

Example 4: Update Packages With “yum”

When you want to update a package or all the packages you can copy this command in Redhat:

sudo yum update
EXPLANATION
  • update: Command to make packages up to date.

Update all packages with yum

From the image, you can see with the update command you can upgrade the packages and to download the upgraded version you have to press the “Y” button to confirm.

Conclusion

From the article, you can notice many differences that an end user can not perceive because these are inside the engine. The key differences are the memory usage, performance, number of code lines, and documentation of API. Besides, the main purpose of the package managers is to manage the RPM packages in your system. So it’s up to you to choose the package manager for your system but it is better to use dnf instead of yum.

People Also Ask

What is the Difference Between Apt and Dnf?

Both are package managers that are used on different distributions. You can use apt in Debian base and dnf in RedHat-based Linux distributions. But Apt and Dnf package managers utilize backend tools like dpkg and rpm respectively.

Does Rhel 8 use DNF?

Yes, It is the new packager manager which you can use to manage packages on RHEL 8.

What is the Difference Between RPM and DNF?

Both package managers are used to handle .rpm packages in RedHat-based Linux distributions like Fedora, and new versions of RHEL. DNF can automatically identify and install dependencies whereas RPM can not.

Should I Use YUM or DNF?

It mainly depends on your preferences. But you should use DNF because it provides better performance, and dependency resolution and also uses less memory.


Related Articles


<< Go Back to Linux Package Manager Comparison | Package Management in Linux | Learn Linux Basics

4.5/5 - (16 votes)
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
Afia Zahin Oishi

Assalamualaikum, I am Afia Zahin, completed my graduation in Biomedical Engineering from Bangladesh University of Engineering and Technology, currently working as a Linux Content Developer Executive at SOFTEKO. A high achieving professional with a strong work ethic and able to work in a team in order to consistently achieve my goal and build my skillset. Able to handle difficult problems with patience and swift decision-making. Read Full Bio

Leave a Comment