dnf (Dandified YUM) is the package manager for AlmaLinux, Rocky Linux, and other RHEL-family distributions — the equivalent of apt on Ubuntu/Debian. This guide covers the essential commands.
Updating the System
sudo dnf update -y
Unlike apt's separate update/upgrade steps, dnf's update command refreshes metadata and installs updates together.
Installing a Package
sudo dnf install nginx -y
Installing Multiple Packages
sudo dnf install nginx mariadb-server php -y
Removing a Package
sudo dnf remove nginx
Searching for a Package
dnf search nginx
Getting Information About a Package
dnf info nginx
Listing Installed Packages
dnf list installed
Checking for Available Updates
dnf check-update
Removing Unused Dependencies
sudo dnf autoremove
Cleaning the Package Cache
sudo dnf clean all
Enabling Extra Repositories (EPEL)
Many useful packages aren't in the default repositories — the EPEL (Extra Packages for Enterprise Linux) repository fills this gap:
sudo dnf install epel-release -y
sudo dnf update -y
Adding a Third-Party Repository
sudo dnf config-manager --add-repo https://example.com/repo.repo
Listing Enabled Repositories
dnf repolist
Installing a Specific Package Version
sudo dnf install nginx-1.24.0 -y
Downgrading a Package
sudo dnf downgrade nginx
Viewing Package Groups
dnf group list
Package groups bundle related software (e.g. "Development Tools") for convenient installation:
sudo dnf group install "Development Tools" -y
Checking Which Package Provides a Specific File
dnf provides /usr/bin/nginx
Viewing Transaction History
sudo dnf history
Undo a specific transaction:
sudo dnf history undo LAST
Automatic Security Updates
sudo dnf install dnf-automatic -y
sudo systemctl enable --now dnf-automatic.timer
Configure to apply only security updates:
sudo nano /etc/dnf/automatic.conf
upgrade_type = security
apply_updates = yes
Quick Reference: apt vs dnf
| Task | apt (Ubuntu/Debian) | dnf (AlmaLinux/Rocky) |
|---|---|---|
| Update system | apt update && apt upgrade | dnf update |
| Install | apt install PKG | dnf install PKG |
| Remove | apt remove PKG | dnf remove PKG |
| Search | apt search PKG | dnf search PKG |
| Clean cache | apt clean | dnf clean all |
Common Errors
"No match for argument" when installing — the package may be in a repository not yet enabled; try enabling EPEL first.
Dependency conflicts:
sudo dnf install PACKAGE --allowerasing
Continue Reading
- How to Get Started with AlmaLinux/Rocky Linux on a VPS
- How to Install Nginx on AlmaLinux/Rocky Linux
- Understanding SELinux Basics on AlmaLinux/Rocky Linux
Browse more articles in AlmaLinux & Rocky Linux.
