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 Dnf?
DNF is the successor of YUM which refers to Dandified YUM and it is the next generation 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.
What is Yum?
In RedHat-based Linux distribution, a primary package for managing software packages is YUM which refers to Yellowdog Updater Modifier. It facilitates the installation, updating, removal, and management of dependencies on a system.
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. | Not documented. |
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 | Can download packages in parallel which speeds up the process. | Can not download parallel packages. |
Plugin | More integrated with the core. | More plugins that increase functionality. |
Modular design | Yes. | No. |
Update and upgrade | Both are the same. | Not same. |
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, there are some key features problem that is solved by dnf and made it smarter than yum. Here I have shown the key feature distinction below:
A. API
As the API of Yum is not documented, it uses the public API, and using public API it is difficult to create new features which are easier in dnf because it used a fully documented API. As dnf has strict API, it allows dnf to develop extensions and plugins.
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 which make dnf built. The problems are:
- Excessive memory use.
- Poor performance.
- Dependency resolution proceeds slowly.
- Use public API for dependency resolution which is not fully documented.
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 a 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
For confirming the installation you have to type Y and then press ENTER.
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
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
- remove: Remove the desired package from the repository.
- totem: The package that I want to remove.
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
- search: Locate a package in the repository.
- httpd: The package which I searched for.
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
- update: Command to make packages up to date.
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.
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
- 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.
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.
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
- remove: Remove the desired package from the repository.
- postgresql: The package that I want to remove.
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
- search: Locate a package in the repository.
- postgresql: The package which I searched for.
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
- update: Command to make packages up to date.
From the image, you can see with the update command you can upgrade the packages and for downloading 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
Related Articles
- Apt Vs Apt-get What’s the Difference?
- Apt Vs Yum [Difference Between the Package Managers]
- Yum Vs Rpm [Which One is Better]
- Dpkg Vs Apt [What’s the Difference Between Package Managers]
- Apt Vs Rpm [Distinction Between Package Managers]
- Deb vs Rpm [Whether One is the Best]
- Apt Vs Pacman [Which One Should Be Utilized]
<< Go Back to Linux Package Manager Comparison | Package Management in Linux | Learn Linux Basics