Installing DNF on RHEL/CentOS 7

DNF (Dandified Yum) is a modern, efficient package manager for RPM-based distributions like RHEL and CentOS, offering faster performance and better dependency resolution than YUM. This guide simplifies installing DNF on an AvaHost RHEL/CentOS 7 VPS, with practical examples to enhance your server management experience.

Prerequisites

  • AvaHost VPS with RHEL 7 or CentOS 7.

  • Root access or sudo privileges (see prior SSH guide).

  • Stable internet connection.

  • Basic Linux command knowledge.

Step 1: Update Your System

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

Step 2: Install the epel-release Repository

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

Step 3: Install DNF

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.

Step 4: Verify the Installation

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

Step 5: Make DNF the Default Package Manager (Optional)

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.

Step 6: Using DNF

You can now use DNF as you would use YUM. Here are some common package management commands:

Install a package:

sudo dnf install package-name

Remove a package:

sudo dnf remove package-name

Update all packages:

sudo dnf update -y

Search for a package:

dnf search package-name

Clean up unused packages:

sudo dnf autoremove -y

Conclusion

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.