DNF Cheatsheet
Basic Commands
Start with package lists and metadata.
| Command | Description |
|---|---|
dnf --version |
Show DNF version |
dnf check-update |
List available updates |
dnf makecache |
Refresh repository metadata cache |
dnf repolist |
List enabled repositories |
dnf repolist all |
List all repositories |
Search and Info
Find packages and inspect details.
| Command | Description |
|---|---|
dnf search nginx |
Search packages by keyword |
dnf info nginx |
Show package details |
dnf provides /usr/bin/python3 |
Find package that provides a file |
dnf list installed |
List installed packages |
dnf list available |
List available packages from repos |
Install and Remove
Install, remove, and reinstall packages.
| Command | Description |
|---|---|
sudo dnf install nginx |
Install one package |
sudo dnf install nginx php-fpm |
Install multiple packages |
sudo dnf remove nginx |
Remove package |
sudo dnf autoremove |
Remove unneeded dependencies |
sudo dnf reinstall nginx |
Reinstall package |
Update and Upgrade
Keep the system and packages up to date.
| Command | Description |
|---|---|
sudo dnf update |
Update installed packages |
sudo dnf upgrade |
Upgrade packages (same effect in most setups) |
sudo dnf upgrade --refresh |
Refresh metadata and upgrade |
sudo dnf update --security |
Apply security updates only |
sudo dnf offline-upgrade download |
Prepare offline upgrade (where supported) |
Groups and Modules
Work with package groups and modular streams.
| Command | Description |
|---|---|
dnf group list |
List package groups |
sudo dnf group install "Development Tools" |
Install package group |
sudo dnf group remove "Development Tools" |
Remove package group |
dnf module list |
List module streams |
sudo dnf module enable nodejs:20 |
Enable a module stream |
sudo dnf module reset nodejs |
Reset module stream |
Repository Management
Enable, disable, and inspect repositories.
| Command | Description |
|---|---|
sudo dnf config-manager --set-enabled repo_id |
Enable repository |
sudo dnf config-manager --set-disabled repo_id |
Disable repository |
dnf repoinfo |
Show repo details |
dnf repoinfo repo_id |
Show one repository details |
sudo dnf clean all |
Clear all cache data |
Query and History
Review installed files and transaction history.
| Command | Description |
|---|---|
rpm -ql nginx |
List files installed by package |
rpm -qf /usr/sbin/nginx |
Find package owning a file |
dnf history |
Show transaction history |
dnf history info 25 |
Show details of transaction ID 25 |
sudo dnf history undo 25 |
Undo transaction ID 25 |
Troubleshooting
Common checks when package operations fail.
| Issue | Check |
|---|---|
| Metadata errors or stale cache | Run sudo dnf clean all then sudo dnf makecache |
| Package not found | Verify enabled repos with dnf repolist and use dnf search |
| Dependency conflicts | Retry with --allowerasing only after reviewing affected packages |
| GPG key error | Import/verify repository GPG key and retry |
| Slow mirror response | Refresh metadata and test another mirror/repo configuration |
Related Guides
Use these references for broader package management workflows.
| Guide | Description |
|---|---|
How to Use apt Command
|
Package management on Ubuntu, Debian, and derivatives |
Linux Commands Cheatsheet
|
General Linux command quick reference |
