- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DNF - The Next Generation Package Management Utility for RPM Based
In the world of RPM-based distributions, keeping your software packages up-to-date is crucial for maintaining system security and stability. Fortunately, dnf provides a powerful and user-friendly package management utility for managing software updates. In this blog post, we will explore the features of dnf and how it improves upon its predecessor, yum.
What is DNF?
DNF is the next-generation package management utility for RPM-based Linux distributions. It is a modern, open-source package manager that is designed to make it easier for users to manage software packages on their systems. DNF stands for "Dandified Yum," which is a reference to its predecessor, Yum.
DNF was first introduced in Fedora 18, and since then, it has become the default package manager for many RPM-based Linux distributions, including Fedora, CentOS 8, and RHEL 8. DNF is based on the same codebase as Yum but with many improvements, including better performance, enhanced security, and a more user-friendly interface.
Why is DNF needed?
Before we dive into the technical details of DNF, let's take a moment to understand why it was created in the first place. The answer to that question lies in the shortcomings of the old Yum package manager.
Yum was designed at a time when RPM-based distributions were still in their infancy. It was a simple tool that could help users manage software packages on their systems, but it had several limitations. For example, it was slow, it didn't handle dependencies very well, and it was prone to errors.
Over time, as RPM-based distributions became more popular and complex, the limitations of Yum became more pronounced. Developers and users alike began to look for a better package manager that could address these issues.
That's where DNF comes in. DNF was designed from the ground up to be a modern, reliable, and easy-to-use package manager. It uses the same RPM package format as Yum, but it has many improvements that make it a superior tool.
How does DNF work?
Now that we understand why DNF was created, let's take a look at how it works. At its core, DNF is a command-line tool that lets users manage software packages on their systems. It can be used to install, update, and remove packages, as well as search for packages and list installed packages.
One of the key features of DNF is its support for plugins. Plugins are modules that can extend the functionality of DNF in various ways. For example, there are plugins that can help with caching, performance tuning, and debugging. Plugins can be installed and configured using the DNF configuration file.
Another key feature of DNF is its use of modular repositories. Modular repositories are collections of software packages that are grouped together based on their functionality. For example, there might be a module for web servers, a module for database servers, and a module for development tools. Each module contains a set of packages that have been tested and verified to work together.
Modular repositories make it easier for users to manage their software packages because they can choose to enable only the modules they need. This helps to reduce the risk of conflicts and ensures that the packages on the system are up-to-date and secure.
Now that we understand how DNF works, let's take a look at how to use it. DNF can be used from the command line or through a graphical interface, such as the GNOME Software application.
To install a package using DNF, simply type the following command −
dnf install package_name
For example, to install the Apache web server, you would type −
dnf install httpd
DNF will then download and install the package and any dependencies that are required.
To update a package using DNF, type the following command −
dnf update package_name
For example, to update the Apache web server, you would type −
dnf update httpd
DNF will then check for updates and download and install any that are available.
To remove a package using DNF, type the following command −
dnf remove package_name
For example, to remove the Apache web server, you would type −
dnf remove httpd
DNF will then remove the package and any dependencies that are no longer required.
DNF also has many other commands and options that can be used to manage packages on the system. For example, you can use the search command to search for packages, the info command to get information about a package, and the list command to list all installed packages.
How DNF Compares to Other Package Managers
DNF is one of several package managers available for RPM-based Linux distributions. Yum, Zypper, and Apt-RPM are other popular package managers. Here are some differences between DNF and these other package managers −
Yum − Yum is the predecessor of DNF and has been around for over a decade. DNF was created to address some of the limitations of Yum, such as slow performance, lack of dependency resolution, and a limited plugin architecture. While Yum is still used in some older versions of RPM-based distributions, DNF is the recommended package manager for newer versions.
Zypper − Zypper is the default package manager for SUSE Linux Enterprise and openSUSE distributions. Like DNF, it has a plugin architecture and supports parallel downloading of packages. However, DNF is generally considered to be faster and more reliable than Zypper, especially when it comes to dependency resolution.
Apt-RPM − Apt-RPM is a port of the Debian package manager (APT) for RPM-based distributions. It has a similar command-line interface and syntax to APT, but it has some limitations when it comes to RPM-specific features such as delta RPMs and package signing. DNF is generally considered to be a better choice for managing RPM-based distributions.
Overall, DNF is a modern, reliable, and easy-to-use package manager that has many advantages over other package managers.
How to Install and Configure DNF
Installing and configuring DNF is straightforward. Here are the steps −
Check your system requirements − DNF requires a minimum of 1GB of RAM and 10GB of free disk space.
Install DNF − To install DNF on a Fedora-based system, run the following command −
sudo dnf install dnf
To install DNF on a Red Hat Enterprise Linux or CentOS system, you will need to enable the EPEL repository first −
sudo yum install epel-release sudo yum install dnf
Configure DNF − DNF is configured through the /etc/dnf/dnf.conf file. Here are some basic configuration options:
installonly_limit − Sets the maximum number of old versions of packages to keep on the system. The default value is 3.
clean_requirements_on_remove − Removes dependencies that are no longer needed when a package is removed. The default value is True.
gpgcheck − Enables or disables package signing verification. The default value is True.
max_parallel_downloads − Sets the maximum number of packages to download at once. The default value is 3.
You can also configure individual repositories by creating a file in the /etc/yum.repos.d/ directory. Here's an example of a repository file for the Fedora Updates repository −
[fedora-updates] name=Fedora $releasever - $basearch - Updates metadata_expire=6h mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f$releasever&arch=$basearch enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
How to Create Your Own DNF Plugin
Creating your own DNF plugin is also relatively easy. Here are the steps −
Create a plugin directory − Create a directory for your plugin in /usr/lib/dnf/plugins/ with a descriptive name. For example −
sudo mkdir /usr/lib/dnf/plugins/myplugin
Create a Python file for your plugin − Create a Python file in your plugin directory with a descriptive name and a .py extension. For example −
sudo nano /usr/lib/dnf/plugins/myplugin/myplugin.py
Define your plugin class − In your Python file, define a class for your plugin that inherits from the dnf.Plugin class. Here's an example −
from dnf.plugins import Plugin class MyPlugin(Plugin): name = 'myplugin' def __init__(self, base, cli): super(MyPlugin, self).__init__(base, cli)
Implement your plugin logic − Add methods to your class that implement the functionality of your plugin. For example −
def posttrans(self): print("My plugin was called after a transaction was completed!")
Register your plugin − In your Python file, add a call to the dnf.plugin.register() function to register your plugin. For example −
from dnf.plugins import Plugin, plugin class MyPlugin(Plugin): name = 'myplugin' def __init__(self, base, cli): super(MyPlugin, self).__init__(base, cli) def posttrans(self): print("My plugin was called after a transaction was completed!") plugin.register(MyPlugin)
Test your plugin − Run DNF with the --verbose and --debugsolver options to see if your plugin is being called. For example −
sudo dnf update --verbose --debugsolver
You should see your plugin being loaded and called in the output.
DNF is the next generation package management utility for RPM-based Linux distributions. It offers many advantages over previous package managers such as Yum, including faster performance, better dependency resolution, and a more flexible plugin architecture. With DNF, you can easily install, update, and remove packages on your system, as well as create your own plugins to extend its functionality.
By following the steps outlined in this blog post, you should be able to install and configure DNF on your system, as well as create your own DNF plugin. Whether you're a system administrator, a developer, or a Linux enthusiast, DNF is a powerful and versatile tool that can help you manage your system more effectively.
Kickstart Your Career
Get certified by completing the courseGet Started