DNF (Dandified Yum) is the next-generation package manager for RPM-based distributions. It replaces YUM with improved dependency resolution, better performance, and a more modern codebase. While RHEL and CentOS 7 come with YUM as the default package manager, users may want to install DNF to leverage its advantages. This guide will walk you through the steps to install DNF on RHEL/CentOS 7.
Before proceeding, ensure that you:
It’s always recommended to update your system before installing new software. Run the following command to ensure all existing packages are up to date:
sudo yum update -y
DNF is not included in the default RHEL/CentOS 7 repositories, so you need to enable the EPEL (Extra Packages for Enterprise Linux) repository:
sudo yum install -y epel-release
Once installed, update the repository metadata:
sudo yum update -y
Now you can install DNF by running:
sudo yum install -y dnf
This command will install the necessary dependencies and set up DNF on your system.
To confirm that DNF has been installed successfully, check its version:
dnf --version
If the installation was successful, you should see output similar to:
DNF version 2.x.x
Since YUM is still the default package manager in RHEL/CentOS 7, you can replace it with DNF for package management tasks. If you wish to use DNF instead of YUM by default, you can create symbolic links:
sudo mv /usr/bin/yum /usr/bin/yum.bak
sudo ln -s /usr/bin/dnf /usr/bin/yum
This ensures that when you run yum
commands, they are redirected to dnf
.
You can now use DNF as you would use YUM. Here are some common package management commands:
sudo dnf install package-name
sudo dnf remove package-name
sudo dnf update -y
dnf search package-name
sudo dnf autoremove -y
Installing DNF on RHEL/CentOS 7 provides an enhanced package management experience with improved performance and better dependency handling. By following this guide, you can easily install and start using DNF on your system. If you plan to upgrade to a newer version of RHEL or CentOS, you’ll already be familiar with DNF, as it is the default package manager in RHEL 8 and later.