dnf Command in Linux: Install, Update & Remove Packages on Fedora and RHEL
Linux distributions based on Red Hat use the package manager called Red Hat Package Manager – RPM to install their software. Among the most famous distributions are Red Hat's own Enterprise Linux, Fedora, and CentOS.
RPM is a powerful package manager that allows the administrator to install, remove, and obtain information about packages. It is a widely used software distribution method across various Linux distributions, in addition to Red Hat.
It also enables building packages from source files, verifying digital signatures, simulating program installations, among others. It's as powerful as dpkg and apt-get.
The Fedora Linux distribution made its own Red Hat-based package manager, called DNF.
DNF is a software package manager that installs, updates, and removes packages on RPM-based Linux distributions, very similar to YUM.
It automatically calculates dependencies and determines the actions required to install packages.
DNF also facilitates maintaining groups of machines, eliminating the need to manually update each one using rpm.
Introduced in Fedora 18, it has been the default package manager since Fedora 22.
For many, DNF or "Dandified Yum" is the next-generation version of Yum.
It maintains Yum's interface compatibility and defines a rigorous API for extensions and plugins. The fact that it allows plugin installation is very welcome, as these can modify or extend DNF's capabilities and provide additional interface commands.
DNF Installation
If DNF is not installed on your Red Hat-based distribution, you can install it using Yum:
# yum install dnf
The commands that DNF accepts are very similar to Yum:
- autoremove: removes a package and its dependencies (only if not used by other programs)
- check: Verifies the RPM database and produces information
- check-update [package name]: Checks if there are updates for packages
- clean: Deletes temporary files from repositories
- distro-sync: Upgrades or downgrades packages to match the latest repository version
- downgrade [package name]: downgrades a package
- group [info] [install] [list] [remove] [upgrade]: Performs commands with software groups
- history: lists the transactions performed
- info [package name]: shows information about a package
- install package_name: installs a specific package and its dependencies
- list: lists installed and available packages
- provide [name]: lists packages that contain the searched name
- remove package_name: removes a specific package
- repolist: lists known repositories
- upgrade [package name]: upgrades a package or all packages if no package name is specified
DNF usage examples are very similar to YUM, since DNF is considered an evolution of YUM.
Conclusion
If you use Fedora or Red Hat, the dnf command is essential for package management on these distributions.
Learn much more about Linux with the RHCSA Exam Prep Course from Linux Certification. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.