Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills
09.10.2024

Install DNF in RHEL/CentOS 7

Install DNF on RHEL/CentOS 7: Upgrade Your Package Game

Why swap YUM for DNF? DNF (Dandified YUM) is the sleek, modern replacement for YUM on RPM-based Linux like Fedora, bringing faster performance, smarter dependency handling, and a cleaner vibe. RHEL/CentOS 7 sticks with old-school YUM, but you can bolt on DNF for that next-gen edge. This guide gets you from YUM to DNF on your AlexHost VPS in a snap—let’s rev up!

Telegram Premium Account Giveaway

Join Now
Telegram Premium Star Star

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!

Test your skills on our all Hosting services and get 15% off!

Use code at checkout:

Skills