Skip to main content

DNF Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for package management with dnf on Fedora, RHEL, and derivatives

DNF is the default package manager on Fedora, RHEL, and many derivatives. This cheatsheet covers common dnf commands for searching, installing, updating, removing, and troubleshooting packages.

Basic Commands

Start with package lists and metadata.

CommandDescription
dnf --versionShow DNF version
dnf check-updateList available updates
dnf makecacheRefresh repository metadata cache
dnf repolistList enabled repositories
dnf repolist allList all repositories

Search and Info

Find packages and inspect details.

CommandDescription
dnf search nginxSearch packages by keyword
dnf info nginxShow package details
dnf provides /usr/bin/python3Find package that provides a file
dnf list installedList installed packages
dnf list availableList available packages from repos

Install and Remove

Install, remove, and reinstall packages.

CommandDescription
sudo dnf install nginxInstall one package
sudo dnf install nginx php-fpmInstall multiple packages
sudo dnf remove nginxRemove package
sudo dnf autoremoveRemove unneeded dependencies
sudo dnf reinstall nginxReinstall package

Update and Upgrade

Keep the system and packages up to date.

CommandDescription
sudo dnf updateUpdate installed packages
sudo dnf upgradeUpgrade packages (same effect in most setups)
sudo dnf upgrade --refreshRefresh metadata and upgrade
sudo dnf update --securityApply security updates only
sudo dnf offline-upgrade downloadPrepare offline upgrade (where supported)

Groups and Modules

Work with package groups and modular streams.

CommandDescription
dnf group listList package groups
sudo dnf group install "Development Tools"Install package group
sudo dnf group remove "Development Tools"Remove package group
dnf module listList module streams
sudo dnf module enable nodejs:20Enable a module stream
sudo dnf module reset nodejsReset module stream

Repository Management

Enable, disable, and inspect repositories.

CommandDescription
sudo dnf config-manager --set-enabled repo_idEnable repository
sudo dnf config-manager --set-disabled repo_idDisable repository
dnf repoinfoShow repo details
dnf repoinfo repo_idShow one repository details
sudo dnf clean allClear all cache data

Query and History

Review installed files and transaction history.

CommandDescription
rpm -ql nginxList files installed by package
rpm -qf /usr/sbin/nginxFind package owning a file
dnf historyShow transaction history
dnf history info 25Show details of transaction ID 25
sudo dnf history undo 25Undo transaction ID 25

Troubleshooting

Common checks when package operations fail.

IssueCheck
Metadata errors or stale cacheRun sudo dnf clean all then sudo dnf makecache
Package not foundVerify enabled repos with dnf repolist and use dnf search
Dependency conflictsRetry with --allowerasing only after reviewing affected packages
GPG key errorImport/verify repository GPG key and retry
Slow mirror responseRefresh metadata and test another mirror/repo configuration

Use these references for broader package management workflows.

GuideDescription
How to Use apt CommandPackage management on Ubuntu, Debian, and derivatives
Linux Commands CheatsheetGeneral Linux command quick reference