dnf: The Fedora and Red Hat Package Manager
dnf (“Dandified YUM”) is the package manager on Fedora and the entire Red Hat family — RHEL, Rocky Linux, AlmaLinux, CentOS Stream. It replaced the older yum command, but on RHEL 8/9 the old name still works as an alias.
Daily commands
# Update package metadata + upgrade everything
sudo dnf upgrade --refresh -y
# Just refresh metadata (rarely needed; dnf does this automatically)
sudo dnf check-update
# Install
sudo dnf install nginx
# Install multiple
sudo dnf install nginx git tmux htop
# Install without prompts
sudo dnf install -y nginx
# Remove
sudo dnf remove nginx
# Remove orphaned dependencies
sudo dnf autoremove
Search and inspect
dnf search nginx # search names + summaries
dnf info nginx # detailed info about a package
dnf list installed # all installed
dnf list available # what's installable
dnf list --upgrades # what would be upgraded
rpm -qa | grep nginx # also list installed
rpm -ql nginx # what files does it install?
rpm -qf /usr/sbin/nginx # which package owns this file?
Group install
dnf groups are bundles of related packages — easier than installing 30 individually.
dnf group list # list available groups
sudo dnf group install "Development Tools"
sudo dnf group install "Container Management"
sudo dnf group remove "Office Suite"
Repositories
dnf repolist # enabled repos
dnf repolist --all # all repos including disabled
sudo dnf config-manager --add-repo URL
sudo dnf config-manager --enable repo-name
sudo dnf config-manager --disable repo-name
Add RPM Fusion (codecs and proprietary stuff on Fedora)
sudo dnf install
https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
Add EPEL (extra packages on RHEL/Rocky/Alma)
sudo dnf install epel-release
sudo dnf upgrade --refresh
Transaction history (dnf’s killer feature)
Every install/remove is a transaction you can roll back:
dnf history # list past transactions
dnf history info 42 # what was in transaction 42
sudo dnf history undo 42 # undo a transaction
sudo dnf history rollback 30 # roll back to transaction 30
This saves you when an upgrade breaks something.
Modules (Application Streams on RHEL)
RHEL 8+ ships multiple versions of language runtimes via “modules”:
dnf module list # all available modules
dnf module list nodejs # versions of nodejs
sudo dnf module enable nodejs:18
sudo dnf module install nodejs
Cleanup
sudo dnf autoremove # remove orphan deps
sudo dnf clean all # clear all caches
The yum compatibility
On RHEL/CentOS/Rocky, you can type yum instead of dnf — it’s a symlink. Same commands work. New scripts should use dnf.
Useful one-liners
# What's about to update? See changelog before applying
dnf updateinfo info security
# Install a package only if it's not installed
sudo dnf install --skip-broken --best nginx
# Find what package provides a missing command
dnf provides */make
sudo dnf install make
# Show package dependencies
dnf repoquery --requires nginx
dnf repoquery --whatrequires nginx # what depends on nginx
Common mistakes
- Forgetting
--refreshondnf upgradein cron jobs — metadata can be stale. - Mixing EPEL and RPM Fusion priorities incorrectly.
- Using
rpm -idirectly to install — bypasses dependency resolution. Usednf install /path/to/file.rpminstead.
What to learn next
If your other machines run Arch, the pacman guide is next. Otherwise, head to the networking section.