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-update

dnf update — Update all packages (alias for upgrade).

sudo dnf update -y

dnf upgrade — Upgrade all installed packages.

sudo dnf upgrade

dnf upgrade --security — Install only security updates.

sudo dnf upgrade --security

dnf upgrade <package> — Upgrade a specific package.

sudo dnf upgrade nginx

Install & Remove

dnf install <package> — Install a package.

sudo dnf install nginx

dnf install -y <package> — Install without confirmation.

sudo dnf install -y httpd php

dnf install <file>.rpm — Install a local RPM file (with dependency resolution).

sudo dnf install ./package.rpm

dnf reinstall <package> — Reinstall a package.

sudo dnf reinstall openssh-server

dnf remove <package> — Remove a package and its unused dependencies.

sudo dnf remove nginx

dnf autoremove — Remove unused dependency packages.

sudo dnf autoremove

Search & Info

dnf search <query> — Search for packages by name or summary.

dnf search nodejs

dnf info <package> — Show detailed info about a package.

dnf info nginx

dnf list installed — List all installed packages.

dnf list installed

dnf list available — List all available packages.

dnf list available | grep php

dnf 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 nginx

dnf deplist <package> — Show dependencies of a package.

dnf deplist nginx

Groups & Modules

dnf group list — List available package groups.

dnf group list

dnf group install '<group>' — Install a package group.

sudo dnf group install 'Development Tools'

dnf module list — List available modules and streams.

dnf module list

dnf module enable <module>:<stream> — Enable a module stream.

sudo dnf module enable nodejs:20

dnf module install <module>:<stream> — Install a module stream.

sudo dnf module install php:8.3

Repositories

dnf repolist — List enabled repositories.

dnf repolist

dnf repolist all — List all repositories (enabled and disabled).

dnf repolist all

dnf config-manager --add-repo <url> — Add a new repository.

sudo dnf config-manager --add-repo https://rpm.example.com/repo.repo

dnf config-manager --set-enabled <repo> — Enable a disabled repository.

sudo dnf config-manager --set-enabled crb

dnf config-manager --set-disabled <repo> — Disable a repository.

sudo dnf config-manager --set-disabled epel-testing

History & Cleanup

dnf history — Show transaction history.

dnf history

dnf history info <id> — Show details of a specific transaction.

dnf history info 15

dnf history undo <id> — Undo a specific transaction.

sudo dnf history undo 15

dnf clean all — Clean all cached data (metadata + packages).

sudo dnf clean all

dnf 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

  • apk – package manager for Alpine Linux, lean and container-friendly
  • apt – the high-level package manager for Debian and Ubuntu
  • apt-get – the classic, script-friendly Debian/Ubuntu tool