Quick take: The dnf command (and its predecessor yum) manages packages on RHEL, Fedora, CentOS, and Rocky Linux. Use sudo dnf install name, sudo dnf update, and dnf search term — the RPM-world equivalents of apt.
Introduction
On Red Hat-family distributions — RHEL, Fedora, CentOS Stream, Rocky, and AlmaLinux — package management is handled by dnf (and the older yum, now an alias for dnf). They install, update, and remove RPM packages while resolving dependencies, just as apt does on Debian systems.
Syntax
The basic syntax of the dnf and yum command is:
dnf [OPTIONS] COMMAND [PACKAGE...]Common Options and Parameters
The most useful options and parameters for the dnf and yum command:
| Option | Description |
|---|---|
| install PKG | Install a package and its dependencies. |
| update [PKG] | Update all packages, or one. |
| remove PKG | Uninstall a package. |
| search TERM | Search for packages by keyword. |
| info PKG | Show details about a package. |
| list installed | List installed packages. |
| provides FILE | Find which package provides a file. |
| group install NAME | Install a package group. |
| -y | Assume yes to prompts. |
Practical Examples
Real dnf and yum commands you can run today:
# Install a package
sudo dnf install nginx
# Update everything
sudo dnf update
# Search for a package
dnf search 'web server'
# Find which package provides a command
dnf provides /usr/bin/htop
# Remove a package
sudo dnf remove nginx
# Install a group of packages
sudo dnf group install 'Development Tools'Tips and Best Practices
- On modern RHEL-family systems
yumis just a symlink todnf; the commands and syntax are identical, so use whichever is present. dnf provides /path/to/fileanswers “which package contains this?” — the equivalent ofdpkg -Son Debian.- Add the EPEL repository (
sudo dnf install epel-release) to access many extra community packages on RHEL/Rocky.
Final Thoughts
dnf (and yum) are the package managers of the Red Hat world, mirroring apt's role on Debian systems. Learn install, update, remove, search, and provides, and you can manage software on RHEL, Fedora, and Rocky with confidence. The concepts transfer directly from apt — only the command name and package format differ.
FAQ: dnf and yum Command in Linux
What is the difference between dnf and yum?+
dnf is the modern package manager for RHEL-family distributions and the successor to yum, with better dependency resolving and performance. On current systems yum is simply a symlink to dnf, so the syntax is the same.
How do I install a package on RHEL or Fedora?+
Use sudo dnf install packagename. dnf downloads the package and its dependencies and installs them, much like apt install on Debian-based systems.
How do I update all packages with dnf?+
Run sudo dnf update (or sudo dnf upgrade) to update every installed package to the latest available version, resolving dependencies automatically.
How do I find which package provides a file?+
Use dnf provides /path/to/file, for example dnf provides /usr/bin/htop, which reports the package that contains it.
What is EPEL?+
EPEL (Extra Packages for Enterprise Linux) is a community repository that adds many packages not in the base RHEL/Rocky repos. Enable it with sudo dnf install epel-release.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support