keepcalculator

06 Numbers and Powers

DNF vs DNF5: Which Package Manager?

Card No. 06·83856 · Updated · Standard formula, shown below

DNF5 is the next-generation version of DNF, the package manager used on Fedora and other RPM-based Linux distributions. It is a complete rewrite in C++ that aims to be faster, use less memory, and have a cleaner codebase than the original DNF (which was written in Python). This article explains the differences, how to choose between them, and what to expect when switching.

Background: Why DNF5 Exists

DNF (Dandified YUM) was introduced in Fedora 18 as a fork of YUM, the older package manager. It was written in Python and used the hawkey/libsolv libraries for dependency resolution. Over time, DNF’s Python codebase became hard to maintain and slower than desired. DNF5 is a ground-up rewrite in C++ that reuses libsolv but drops the Python layer. The goal is to reduce complexity, improve performance, and make the codebase more maintainable for the future.

Key Differences: Speed, Memory, and Code

  • Speed: DNF5 is significantly faster, especially for operations like listing installed packages or running dependency resolution. The C++ implementation avoids Python’s overhead and uses more efficient data structures.
  • Memory: DNF5 uses less RAM because it doesn’t load a Python interpreter. On systems with limited memory, this can make a noticeable difference.
  • Codebase: DNF5 is a single C++ binary, whereas DNF is a Python application with many modules. This makes DNF5 easier to package and maintain.
  • Command compatibility: Most DNF commands work the same in DNF5, but there are some minor differences in output formatting and certain options. For example, the --allowerasing flag is still supported, but some deprecated options have been removed.

How DNF5 Works

DNF5 uses the same underlying libraries as DNF, notably libsolv for dependency resolution and librepo for downloading packages. The main difference is that everything is compiled into a single binary. The configuration files (/etc/dnf/dnf.conf) and repository files (/etc/yum.repos.d/) are compatible, so existing setups work without changes. DNF5 also supports the same transaction history and undo features.

How to Choose: Which Should You Use?

If you are on Fedora 41 or later, DNF5 is the default and you should use it. For older Fedora versions or other distributions like RHEL, you might have the option to install DNF5 manually, but it’s not always recommended because it may not be fully tested with your system’s repositories. If you are a developer or system administrator who wants the latest features and performance, DNF5 is a good choice. For most users, the default package manager on their distribution is the best option.

Common Problems and Migration Issues

  • Plugins: Some DNF plugins are not yet compatible with DNF5. If you rely on a specific plugin, check its compatibility before switching.
  • Output differences: The output of commands like dnf list may look slightly different in DNF5. Scripts that parse DNF output may need updates.
  • Missing options: A few rarely used options from DNF are not implemented in DNF5. Check the man page for a full list.
  • Transaction history: DNF5 stores history in a different format, but it can read the old DNF history. If you need to rollback a transaction from before the switch, you can still do it.

Comparison: DNF vs YUM vs DNF5

YUM was the original package manager for RPM-based systems, written in Python. DNF was a fork of YUM that improved dependency resolution and performance. DNF5 is a rewrite of DNF in C++. The table below summarizes the main differences:

  • YUM: Older, slower, no longer maintained. Used on RHEL 7 and earlier.
  • DNF: Current default on Fedora 40 and earlier, RHEL 8/9. Python-based.
  • DNF5: Default on Fedora 41+, faster, C++-based.

Costs and Licensing

Both DNF and DNF5 are free and open-source software, licensed under the GPLv2. There are no licensing costs. The main “cost” of switching is the time to migrate any custom scripts or plugins, and the potential for temporary incompatibilities.

Safety and Stability

DNF5 is considered stable for production use on Fedora. It has been in development for several years and is used by default on Fedora 41 and later. However, as with any major change, there may be edge cases. If you are using a distribution that still relies on DNF (like RHEL), it is safer to stick with the default package manager unless you have a specific reason to switch. Always backup your system before making significant changes to your package manager.

Frequently Asked Questions

Can I install DNF5 on Fedora 40?

Yes, you can install DNF5 manually on Fedora 40 using sudo dnf install dnf5. However, it may not be fully integrated, and some plugins might not work. It’s generally recommended to wait for your distribution to make it the default.

Will DNF5 break my system?

DNF5 is designed to be a drop-in replacement for DNF. In most cases, it will not break your system. However, if you have custom scripts that rely on DNF’s exact output, they may need adjustment. Always test on a non-critical system first.

Is DNF5 faster than DNF?

Yes, DNF5 is noticeably faster, especially for operations like listing packages or resolving dependencies. The exact speedup depends on your system and the operation, but users often report 2-3x faster performance.

Can I use DNF5 on RHEL or CentOS?

DNF5 is not the default on RHEL or CentOS, but you can install it from EPEL or build it from source. However, it is not officially supported by Red Hat for RHEL, so use it at your own risk.

What is the difference between DNF and YUM?

DNF is a fork of YUM that uses the libsolv library for better dependency resolution. It is faster and more reliable. YUM is deprecated and no longer maintained.

How do I switch back to DNF if I don’t like DNF5?

On Fedora, you can install DNF and use dnf instead of dnf5. However, note that DNF and DNF5 share the same transaction history, so you can switch back and forth without issues.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →