dnf — Package Management on Fedora and RHEL
Practical guide to dnf, the package manager for Fedora, RHEL and CentOS Stream — installing, updating, modules, groups plus history and rollback.
dnf (Dandified YUM) is the package manager for Fedora, RHEL 8+, CentOS Stream as well as Rocky Linux and AlmaLinux – the successor to the classic yum with faster, cleaner dependency resolution. You use it to install, update and remove software, manage repositories and work with modules and groups to pick whole software stacks or specific version streams on purpose. Its transaction history is especially handy: every action is logged, and dnf history undo lets you roll back a botched install or a failed update. This guide walks you through the dnf commands you reach for daily – from updating through modules to rollback.
Update & Upgrade
dnf check-update — Check for available package updates.
sudo dnf check-updatednf update — Update all packages (alias for upgrade).
sudo dnf update -ydnf upgrade — Upgrade all installed packages.
sudo dnf upgradednf upgrade --security — Install only security updates.
sudo dnf upgrade --securitydnf upgrade <package> — Upgrade a specific package.
sudo dnf upgrade nginxInstall & Remove
dnf install <package> — Install a package.
sudo dnf install nginxdnf install -y <package> — Install without confirmation.
sudo dnf install -y httpd phpdnf install <file>.rpm — Install a local RPM file (with dependency resolution).
sudo dnf install ./package.rpmdnf reinstall <package> — Reinstall a package.
sudo dnf reinstall openssh-serverdnf remove <package> — Remove a package and its unused dependencies.
sudo dnf remove nginxdnf autoremove — Remove unused dependency packages.
sudo dnf autoremoveSearch & Info
dnf search <query> — Search for packages by name or summary.
dnf search nodejsdnf info <package> — Show detailed info about a package.
dnf info nginxdnf list installed — List all installed packages.
dnf list installeddnf list available — List all available packages.
dnf list available | grep phpdnf provides '<file>' — Find which package provides a file or command.
dnf provides '*/bin/dig'dnf repoquery -l <package> — List files that a package installs.
dnf repoquery -l nginxdnf deplist <package> — Show dependencies of a package.
dnf deplist nginxGroups & Modules
dnf group list — List available package groups.
dnf group listdnf group install '<group>' — Install a package group.
sudo dnf group install 'Development Tools'dnf module list — List available modules and streams.
dnf module listdnf module enable <module>:<stream> — Enable a module stream.
sudo dnf module enable nodejs:20dnf module install <module>:<stream> — Install a module stream.
sudo dnf module install php:8.3Repositories
dnf repolist — List enabled repositories.
dnf repolistdnf repolist all — List all repositories (enabled and disabled).
dnf repolist alldnf config-manager --add-repo <url> — Add a new repository.
sudo dnf config-manager --add-repo https://rpm.example.com/repo.repodnf config-manager --set-enabled <repo> — Enable a disabled repository.
sudo dnf config-manager --set-enabled crbdnf config-manager --set-disabled <repo> — Disable a repository.
sudo dnf config-manager --set-disabled epel-testingHistory & Cleanup
dnf history — Show transaction history.
dnf historydnf history info <id> — Show details of a specific transaction.
dnf history info 15dnf history undo <id> — Undo a specific transaction.
sudo dnf history undo 15dnf clean all — Clean all cached data (metadata + packages).
sudo dnf clean alldnf makecache — Rebuild the metadata cache.
sudo dnf makecache Conclusion
dnf takes the tedious dependency work off your hands and makes maintaining a Fedora or RHEL system clear and reproducible. Treat removing actions like remove, autoremove and distro-sync with care – they can clear out more than you expect, so review the announced package list before you confirm. Modifying commands need sudo; if an update ever breaks something, dnf history undo <id> is your lifeline to cleanly roll back the last transaction. Only add repositories and GPG keys from sources you trust – third-party repos can slip in arbitrary packages.
Further Reading
- dnf documentation – official reference for commands and options
- Fedora docs: Managing software with dnf – official introduction to package management