Differences Between YUM and DNF | Best 1 Comparison

Posted on

Differences Between YUM and DNF | Best 1 Comparison

Differences Between YUM and DNF | Best 1 Comparison

In this article, we aim to dissect the Differences between YUM and DNF package managers (Yum vs DNF). As many Linux administrators know, YUM has been the long-standing package manager for Red Hat Enterprise Linux (RHEL)-based distributions. However, due to its shortcomings in performance and resource consumption, DNF emerged as its successor in newer RHEL-based systems.

Let’s delve into the core of YUM and DNF, highlighting their key distinctions. Continue reading to gain a comprehensive understanding of the Differences Between YUM and DNF | Best 1 Comparison.

What is YUM?

YUM, which stands for Yellowdog Updater Modified, is a command-line package management tool used for managing software packages on Linux systems that utilize the RPM Package Manager. It is primarily used on Red Hat-based distributions. With YUM, you can perform tasks such as:

  • Installing new software packages.
  • Updating existing software packages.
  • Removing software packages.
  • Managing package dependencies.
  • Searching for software packages.

What is DNF?

DNF, short for Dandified Yum, is the next-generation package manager for RPM-based Linux distributions. It builds upon the foundations of YUM but introduces significant improvements in performance, dependency resolution, and overall user experience. DNF effectively replaces YUM in modern RHEL-based distributions, offering a more efficient and robust package management solution. DNF performs similar management processes as YUM.

Now, let’s explore the specific differences between YUM and DNF, along with some of their most commonly used commands. Understanding the Differences Between YUM and DNF | Best 1 Comparison is crucial for any Linux system administrator.

What are the differences between YUM and DNF package managers?

Over time, YUM began to exhibit certain limitations:

  • Slow dependency resolution.
  • High memory consumption.
  • Limited support for parallel downloads.
  • Difficulties in handling complex dependency scenarios.

These issues led to the decision to replace YUM with DNF on CentOS 8, AlmaLinux 8, Rocky Linux, and Fedora.

DNF leverages "libsolv" for dependency resolution. This library, developed and maintained by SUSE, is written in C, C++, and Python, leading to significant performance gains.

YUM, on the other hand, utilizes a public API for dependency resolution. However, this API is not fully documented, and YUM is written solely in Python.

The question arises: why build a new tool instead of fixing the existing problems with YUM?

Why DNF has been built?

The consensus was that addressing the fundamental issues within YUM was not technically feasible. Furthermore, the YUM development team was reportedly resistant to incorporating the necessary changes.

The sheer size of the YUM codebase (56,000 lines of code) compared to DNF (29,000 lines of code) made a complete overhaul impractical.

Despite this shift, YUM remains functional on Red Hat Enterprise Linux 6/7 (RHEL), CentOS 6/7, and Oracle Enterprise Linux 6/7 (OEL).

While YUM is still present on CentOS 8 and AlmaLinux 8, DNF is the recommended package manager. The Differences Between YUM and DNF | Best 1 Comparison highlights the benefits of switching to DNF.

Let’s examine a more detailed comparison of YUM and DNF.

YUM vs DNF

No. DNF (Dandified yum) Yum (YellowDog Updater Modified)
1 DNF supports various extensions YUM supports only Python-based extensions
2 In the DNF the API is well-documented so it’s easy to create new features In the YUM It is very difficult to create new features because the API is not properly documented
3 DNF uses less memory when synchronizing the metadata of the repositories YUM uses excessive memory when synchronizing the metadata of the repositories
4 dnf update and dnf upgrade are equal but in the yum it’s different
5 The dependencies on package installation are not updated in the DNF Yum offered an option for this behavior
6 Kernel packages are not protected by dnf with Yum, you can delete all kernel packages, including one that runs
7 When removing a package, dnf automatically removes any dependency packages not explicitly installed by the user YUM didn’t do this
8 If the enabled repository does not respond, dnf will skip it and continue the transaction with the available repositories If a repository is not available, YUM will stop immediately
9 All performance is good in terms of memory usage and dependency resolution of repository metadata in DNF In the yum Overall performance is poor in terms of many factors
10 By default, ten minutes after the system boots, updates to configured repositories are checked by dnf hourly. Also for yum too. This action is controlled by the system timer unit named “/usr/lib/systemd/system/dnf-makecache.timer”

Examples of DNF and Yum Package Manager Commands

Let’s begin with a common task performed after installing a new Linux distribution: downloading system updates. The Differences Between YUM and DNF | Best 1 Comparison extend to command usage.

Download System Updates

To install system updates using DNF, execute:

sudo dnf update -y
Or
sudo dnf upgrade -y

To install system updates using YUM, execute:

sudo yum update -y

sudo provides administrative privileges. Without it, the command will fail due to insufficient permissions.

The update command downloads metadata about the packages from available software sources.

Search for a Package

To search for a program named "package," type:

sudo dnf search package
sudo yum search package

Install Software

The command to install a program using YUM or DNF is the same:

sudo dnf install package
or
sudo yum install package

Both DNF and YUM allow you to install RPMs downloaded from the web. Use the install command with the full path to the RPM:

sudo dnf install /path/to/package.rpm
or
sudo yum install /path/to/package.rpm

Uninstall Software

To uninstall a program using DNF, run:

sudo dnf remove package

To automatically remove unneeded dependencies, use:

sudo dnf autoremove

This also works for YUM.

The most common DNF and YUM commands

No. Yum and DNF commands Explanations
1 dnf install package-name Install a Software package
or
yum install package-name
2 dnf upgrade package-name Upgrade or Update a Software package
or
yum upgrade package-name
3 dnf search package-name It looks for the desired package in the repository
or
yum search package-name
4 dnf remove package-name Removes the desired package
or
yum remove package-name
5 dnf info package-name It gives information about the desired package
or
yum info package-name
6 dnf list installed It gives a list of installed packages
or
yum list less

Conclusion

This article has explored the Differences Between YUM and DNF | Best 1 Comparison, highlighting why DNF is generally preferred over YUM. We’ve also covered common DNF and YUM commands.

Alternative Solutions: Package Management with Microdnf and Flatpak

While DNF offers significant improvements over YUM, other package management solutions provide different advantages and cater to specific needs. Two such alternatives are Microdnf and Flatpak.

1. Microdnf: A Lightweight DNF

Microdnf is a lightweight version of DNF designed for minimal environments like containers and embedded systems. It focuses on essential package management tasks and reduces dependencies and disk space requirements compared to the full DNF implementation.

Explanation:

Microdnf addresses the need for a smaller, more efficient package manager in resource-constrained environments. It achieves this by removing less critical features and dependencies, resulting in a smaller footprint and faster startup times. This makes it ideal for use in Docker containers, where image size is a major consideration, and in embedded systems with limited storage and processing power. The Differences Between YUM and DNF | Best 1 Comparison don’t directly apply here, as Microdnf is more about a different use case.

Code Example:

Microdnf commands are similar to DNF, but with a reduced set of options. Here are a few examples:

# Update the package database
microdnf update

# Install a package
microdnf install <package_name>

# Remove a package
microdnf remove <package_name>

# List installed packages
microdnf list installed

These commands provide the core functionality needed for package management in a minimal environment.

2. Flatpak: Application Sandboxing and Distribution

Flatpak is a universal package manager that focuses on application distribution and sandboxing. It allows applications to run in isolated environments, preventing them from interfering with the core system or other applications.

Explanation:

Unlike DNF, which manages system-level packages, Flatpak focuses on distributing and managing applications in a platform-independent manner. Flatpak packages contain all the dependencies required to run an application, ensuring consistency and portability across different Linux distributions. The sandboxing feature enhances security by limiting an application’s access to system resources. This approach addresses the problem of dependency conflicts and provides a more secure and reliable way to distribute and run applications. Again, the Differences Between YUM and DNF | Best 1 Comparison aren’t relevant as Flatpak has a distinct purpose.

Code Example:

Here are some common Flatpak commands:

# Add a Flatpak repository
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

# Install an application
flatpak install flathub <application_id>

# Run an application
flatpak run <application_id>

# Update installed applications
flatpak update

# List installed applications
flatpak list

These commands allow users to easily install, run, and manage applications distributed as Flatpak packages.

By considering Microdnf and Flatpak, users can choose the package management solution that best suits their specific needs and environment.