Lesson 76: dnf Command
In this lesson, you'll learn how to use the dnf command to install, update, remove, and manage software packages on RPM-based Linux distributions.
dnf (Dandified YUM) is a next-generation package manager for RPM-based distributions.
It was first introduced in Fedora 18 and has replaced the YUM utility in the recent release of Fedora 22.
dnf aims at improving the bottlenecks of YUM, namely, performance, memory usage, dependency resolution, speed, and many other factors. dnf does package management using RPM, libsolv, and the Hawkey library.
The latest stable release of dnf is 4.16.2 (at the time of writing of this ebook), which was released on 27 July 2023.
It (and all previous versions of dnf) is mostly written in Python and is released under GPL v2 License.
Install dnf
dnf has replaced YUM as the default package manager on most newer RPM-based distributions, including:
- RHEL (Red Hat Enterprise Linux) 8
- CentOS 8 and other RHEL derivatives (such as AlmaLinux 8 and Rocky Linux 8)
- Fedora 22 (and later)
However, if you are using older versions of these distros that do not come with dnf, you can install dnf on RHEL/CentOS systems by first installing and enabling the epel-release repository.
# yum install epel-release
Or:
# yum install epel-release -y
Though it is not ethical to use -y with the yum package manager, as it is recommended to see what is being installed in your system.
However, if this does not matter to you much, you may use -y with yum to install everything automatically without user intervention.
Next, install the dnf package using the yum command from the epel-release repository.
# yum install dnf
Your dnf will install successfully. Let's see some practical usage of dnf commands with examples that will help you manage packages in RPM-based distributions easily and effectively.
dnf Command Syntax
# dnf [OPTIONS] [COMMAND] [PACKAGE]