📒 

DNF (Dandified YUM) is the next-generation package manager for RPM-based Linux distributions. It replaces YUM in more recent versions of Fedora and RHEL/CentOS. However, in RHEL/CentOS 7, the default package manager is still YUM. If you want to use DNF on RHEL/CentOS 7, you can manually install it. This guide will show you how to do so.

Prerequisites

  • A running instance of RHEL 7 or CentOS 7.
  • Root or sudo access to install packages.

Step 1: Update System Packages

Before installing DNF, update your existing packages to ensure compatibility:

sudo yum update -y

Step 2: Enable the EPEL Repository

The Extra Packages for Enterprise Linux (EPEL) repository provides additional packages for RHEL/CentOS, including DNF. To enable EPEL, run the following command:

sudo yum install epel-release -y

This command will enable the EPEL repository, which contains the DNF package.

Step 3: Install DNF

Now that the EPEL repository is enabled, you can install DNF:

sudo yum install dnf -y

This will install the DNF package along with its dependencies.

Step 4: Verify the Installation

To ensure that DNF has been installed successfully, check the version:

dnf –version

This command should display the installed DNF version, indicating that the installation was successful.

Step 5: Using DNF as a Package Manager

Now that DNF is installed, you can use it alongside YUM. Here are some basic DNF commands:

  • Update all packages:
    sudo dnf update -y
  • Install a package:
    sudo dnf install package-name -y
  • Remove a package:
    sudo dnf remove package-name -y
  • Search for a package:
    dnf search package-name
  • List all installed packages:
    dnf list installed

Optional: Replace YUM with DNF

While it’s generally not necessary to replace YUM with DNF completely on RHEL/CentOS 7, you can create an alias for DNF to simplify usage:

  1. Create an Alias:Add the following line to your ~/.bashrc file:
    alias yum=dnf
  2. Apply the Alias:Reload the .bashrc file to apply the changes:
    source ~/.bashrc

Now, whenever you use the yum command, it will automatically run dnf.

Conclusion

You have successfully installed DNF on RHEL/CentOS 7. DNF offers improved performance, better dependency resolution, and newer features compared to YUM. While RHEL/CentOS 7 does not use DNF by default, this guide allows you to take advantage of DNF’s capabilities on older systems. Enjoy managing your packages with the power and flexibility of DNF!