Fedora package commands have changed enough that old yum, groupinstall, and DNF4 config-manager --add-repo examples can fail on current systems. This Fedora DNF command line cheat sheet keeps the familiar dnf command in view while calling out DNF5 syntax where it changes real terminal behavior.
Use these Fedora DNF commands as a quick terminal reference for updates, searches, installs, removals, repositories, groups, history, cache cleanup, offline transactions, and common troubleshooting. The examples target normal mutable Fedora Workstation, Server, and minimal installs; Fedora Atomic desktops and rpm-ostree systems use a different host update model.
Fedora DNF Command Line Cheat Sheet Quick Reference
Start with the commands Fedora users reach for most often. Commands without sudo only query package metadata or local package state. Commands with sudo can change installed packages, repositories, caches, or pending offline transactions.
| Task | Command | What It Does |
|---|---|---|
| Check Fedora release | cat /etc/fedora-release | Prints the Fedora edition and release number. |
| Check DNF version | dnf --version | Shows whether the command is backed by DNF5 and which library versions are installed. |
| Refresh metadata and upgrade | sudo dnf upgrade --refresh | Refreshes enabled repositories and upgrades installed packages. |
| Check available upgrades | dnf check-upgrade | Lists packages with newer candidates without applying the transaction. |
| Search package names | dnf search --name <term> | Searches package names for a short term. |
| Show package details | dnf info <package> | Displays package version, repository, size, summary, and description. |
| Find the package for a command | dnf provides '*/<command>' | Finds packages that provide a matching executable or file path. |
| Install a package | sudo dnf install <package> | Installs the package and required dependencies after transaction review. |
| Preview an install | sudo dnf install --assumeno <package> | Shows the planned transaction and exits without installing anything. |
| Remove a package | sudo dnf remove <package> | Removes the package and any dependency removals included in the reviewed transaction. |
| List enabled repositories | dnf repo list --enabled | Shows repositories currently used for package metadata and transactions. |
| List all repositories | dnf repo list --all | Shows enabled and disabled repositories with their IDs. |
| List package groups | dnf group list --hidden | Lists visible and hidden package groups, including group IDs used by DNF5. |
| Review transaction history | dnf history list | Shows recent DNF transactions and their IDs. |
| Inspect one transaction | dnf history info <id> | Prints package changes made by a specific transaction. |
| Clean metadata cache | sudo dnf clean metadata | Removes cached repository metadata so DNF downloads fresh metadata next time. |
Read Fedora DNF Syntax Safely
Cheat sheets use placeholders for values that depend on your system. Replace the placeholder and remove the angle brackets before running the command. For example, sudo dnf install <package> becomes sudo dnf install vim, not sudo dnf install <vim>.
Review every DNF transaction before confirming it. Package upgrades, removals, repository changes, and history rollbacks can affect services, desktop applications, kernels, drivers, and development toolchains.
Confirm the Fedora release and DNF backend when you are comparing examples from older articles or forum posts:
cat /etc/fedora-release
dnf --version
On current Fedora releases, the version output starts with dnf5 version. Exact patch versions change during Fedora updates, so use the prefix and command help as the stable proof:
dnf install --help
man dnf5
Avoid older YUM-era command forms in new Fedora instructions. Use dnf install ./package.rpm instead of localinstall, dnf group install <group-id> instead of groupinstall, and DNF5 config-manager syntax instead of DNF4-only options.
Update Fedora Packages with DNF
Fedora package maintenance usually starts with dnf upgrade. The --refresh option tells DNF to check enabled repositories for current metadata before calculating the transaction.
| Task | Command | What It Does |
|---|---|---|
| Upgrade installed packages | sudo dnf upgrade --refresh | Refreshes metadata and applies available package upgrades after confirmation. |
| Check pending upgrades | dnf check-upgrade | Lists packages that have available upgrades. |
| Upgrade one package | sudo dnf upgrade <package> | Upgrades a named installed package when a newer candidate exists. |
| Apply minimal security fixes when available | sudo dnf upgrade --minimal --security | Prefers the smallest available updates that satisfy security advisories. |
| Synchronize installed packages with enabled repositories | sudo dnf distro-sync | Aligns installed package versions with repository candidates, including downgrades when needed. |
| Review automatic update setup | systemctl list-timers 'dnf*' | Shows DNF-related timers when automatic update tooling is installed. |
Use a reviewable routine on desktops and servers:
dnf check-upgrade
sudo dnf upgrade --refresh
For scheduled update behavior, use the dedicated walkthrough to install and configure DNF Automatic on Fedora. For performance tuning, review the separate notes on how to increase DNF speed on Fedora.
Search and Inspect Fedora Packages
DNF query commands do not need sudo. Use them before installing, removing, or enabling repositories so you know which package, repository, or file path you are acting on.
| Task | Command | What It Does |
|---|---|---|
| Search package names | dnf search --name <term> | Finds packages with matching names. |
| Search names and descriptions | dnf search <term> | Searches broader package metadata when the exact package name is unknown. |
| Show package details | dnf info <package> | Shows package metadata, repository, license, and description. |
| Show installed package details | dnf info --installed <package> | Limits package information to installed packages. |
| List installed packages | dnf list --installed | Lists packages installed on the system. |
| List available packages | dnf list --available | Lists packages available from enabled repositories. |
| Show available versions | dnf list --showduplicates <package> | Shows multiple available versions when repositories expose them. |
| Find a package by command name | dnf provides '*/semanage' | Finds packages that ship a matching executable name. |
| Find the owner of an installed file | rpm -qf /usr/bin/dnf | Shows which installed RPM owns a file already present on the system. |
| Verify an installed package | rpm -q <package> | Returns the installed package name and version or reports that it is not installed. |
For example, search for the package that provides the SELinux semanage command:
dnf provides '*/semanage'
Then inspect the likely package before installing it:
dnf info policycoreutils-python-utils
Install and Remove Packages with DNF
DNF install and remove commands calculate a transaction and ask for confirmation by default. Read the package list carefully, especially when a command proposes removals, replacements, downgrades, or packages from third-party repositories.
| Task | Command | What It Does |
|---|---|---|
| Install one package | sudo dnf install <package> | Installs the named package and required dependencies. |
| Install several packages | sudo dnf install <package1> <package2> | Installs multiple packages in one reviewed transaction. |
| Preview an install | sudo dnf install --assumeno <package> | Calculates the transaction and exits without changing packages. |
| Install a local RPM file | sudo dnf install ./package.rpm | Installs a local RPM while resolving dependencies from enabled repositories. |
| Download packages without installing | sudo dnf install --downloadonly <package> | Downloads packages and dependencies for the transaction without applying it. |
| Reinstall a package | sudo dnf reinstall <package> | Reinstalls package-owned files from the repository copy. |
| Remove a package | sudo dnf remove <package> | Removes the package and reviewed dependency removals. |
| Remove without automatic dependency cleanup | sudo dnf remove --no-autoremove <package> | Removes the named package while leaving automatically installed dependencies in place. |
| Remove unused dependencies | sudo dnf autoremove | Removes packages marked as automatically installed and no longer required. |
| Prune old install-only packages | sudo dnf remove --oldinstallonly --limit=2 | Removes older install-only packages while keeping the newest two entries, commonly used for kernels. |
Keep -y out of routine desktop and server commands until you already understand the transaction. For deeper package transaction examples, including local RPM files and dependency options, use the focused Fedora guide to Fedora dnf install examples.
Manage Fedora Repositories with DNF
Repository commands decide where DNF reads package metadata. Before enabling, disabling, or adding a source, identify its repository ID with dnf repo list --all and confirm that the source is intended for your Fedora release.
| Task | Command | What It Does |
|---|---|---|
| List enabled repositories | dnf repo list --enabled | Shows repositories currently active for package operations. |
| List disabled and enabled repositories | dnf repo list --all | Shows every configured repository and its enabled state. |
| Inspect a repository | dnf repo info <repo-id> | Shows repository details for a specific repository ID. |
| Check config-manager availability | dnf config-manager --help | Confirms whether the DNF5 config-manager command is available. |
| Install config-manager provider | sudo dnf install 'dnf5-command(config-manager)' | Installs the DNF5 command provider when config-manager is missing. |
| Add a repository file | sudo dnf config-manager addrepo --from-repofile=https://example.com/example.repo | Adds a repository from a vendor-provided .repo file URL. |
| Disable a repository | sudo dnf config-manager setopt <repo-id>.enabled=0 | Disables the repository by setting its enabled option to false. |
| Enable a repository | sudo dnf config-manager setopt <repo-id>.enabled=1 | Enables the repository by setting its enabled option to true. |
| Verify repository state | dnf repo list --all | Confirms whether the repository is enabled or disabled after the change. |
On current Fedora systems, avoid DNF4-only repository examples such as dnf config-manager --add-repo, dnf config-manager --enable, and dnf config-manager --disable. For the most common third-party Fedora repository setup, use the separate walkthrough to install RPM Fusion on Fedora instead of building a generic repository command by hand.
Work with DNF Groups on Fedora
DNF groups install related packages together, such as development tools or desktop components. Current Fedora uses the dnf group command family; do not use older aliases such as groupinstall or groupremove in current Fedora instructions.
| Task | Command | What It Does |
|---|---|---|
| List visible groups | dnf group list | Shows standard visible package groups. |
| List hidden groups too | dnf group list --hidden | Includes hidden groups and IDs that may not appear in the default list. |
| Inspect a group | dnf group info <group-id> | Shows mandatory, default, and optional packages for the group. |
| Install a group | sudo dnf group install <group-id> | Installs packages selected by the group definition. |
| Upgrade a group | sudo dnf group upgrade <group-id> | Applies group changes and upgrades installed group packages. |
| Remove a group | sudo dnf group remove <group-id> | Removes packages that belong to the selected group transaction. |
Prefer group IDs from dnf group list --hidden or dnf group info over display names copied from older examples. For a detailed group workflow, see the Fedora reference for DNF5 group commands on Fedora.
Review DNF History and Reverse Mistakes
DNF records package transactions so you can inspect what changed. History commands are useful after an unexpected removal, a third-party repository issue, or an upgrade that changed more packages than expected.
| Task | Command | What It Does |
|---|---|---|
| List recent transactions | dnf history list | Shows transaction IDs, dates, actions, and package counts. |
| Inspect one transaction | dnf history info <id> | Shows the packages installed, upgraded, removed, or downgraded in a transaction. |
| Undo one transaction | sudo dnf history undo <id> | Attempts to reverse all actions from the selected transaction. |
| Redo one transaction | sudo dnf history redo <id> | Attempts to repeat all actions from the selected transaction. |
| Rollback after an ID | sudo dnf history rollback <id> | Attempts to undo transactions performed after the selected transaction. |
Always inspect the target transaction before undoing or rolling back. Replace 15 with the transaction ID from your own history list:
dnf history list
dnf history info 15
If the transaction summary matches the change you want to reverse, run the undo command and review the proposed package changes before confirming:
sudo dnf history undo 15
History operations are not guaranteed to succeed if repositories changed, packages disappeared, or a newer package set cannot satisfy the older dependency graph. Treat the transaction summary as the final decision point before confirming the reversal.
Clean DNF Cache and Disk Space
DNF caches metadata and downloaded packages under system cache directories. Cleaning the cache can free disk space or force DNF to fetch fresh repository metadata, but it also means the next operation may download more data.
| Task | Command | What It Does |
|---|---|---|
| Check filesystem space | df -h / | Shows used and available space on the root filesystem. |
| Estimate DNF cache size | sudo du -sh /var/cache/dnf | Shows the approximate DNF cache directory size. |
| Clean metadata | sudo dnf clean metadata | Removes cached repository metadata. |
| Clean downloaded packages | sudo dnf clean packages | Removes cached package files. |
| Clean all DNF cache types | sudo dnf clean all | Removes metadata, packages, and other cached DNF data. |
| Expire metadata | sudo dnf clean expire-cache | Marks metadata expired so DNF refreshes it on the next operation. |
The dnf clean command accepts cache types such as metadata, packages, dbcache, expire-cache, and all. It does not clean a single repository by passing a repository ID.
If the space problem is broader than DNF cache, use the df command examples to confirm the affected filesystem, then use the du disk usage examples to trace large directories before deleting unrelated data.
Use Offline and Release Upgrade DNF Commands
Current Fedora dnf includes offline package transactions and the Fedora release upgrade plugin. Treat this section as command orientation; full release upgrades need backups, power checks, third-party repository review, and a clear rollback plan.
| Task | Command | What It Does |
|---|---|---|
| Prepare an offline upgrade | sudo dnf upgrade --refresh --offline | Downloads and stores an upgrade transaction for offline execution. |
| Prepare an offline install | sudo dnf install --offline <package> | Stores an install transaction to apply in the offline environment. |
| Show offline transaction status | sudo dnf offline status | Reports whether an offline transaction is queued. |
| Show offline transaction logs | sudo dnf offline log | Displays logs from completed offline transactions. |
| Clean a queued offline transaction | sudo dnf offline clean | Removes stored offline transaction data and cached package files. |
| Start a queued offline transaction | sudo dnf offline reboot | Reboots into the offline transaction environment after a transaction has been prepared. |
| Check release upgrade commands | dnf system-upgrade --help | Shows available release upgrade subcommands. |
| Download a release upgrade transaction | sudo dnf system-upgrade download --releasever=<version> | Downloads packages needed for a Fedora release upgrade after you choose the target version. |
| Reboot into a staged release upgrade | sudo dnf system-upgrade reboot | Starts the staged Fedora release upgrade transaction. |
| Clean staged release upgrade data | sudo dnf system-upgrade clean | Removes stored release upgrade data and cached packages. |
For command-level details, read the Fedora article on the DNF5 system-upgrade command on Fedora. For a complete release upgrade workflow, use the step-by-step guide to upgrade Fedora Linux to a newer release.
Troubleshoot Common DNF Problems on Fedora
Most DNF problems become easier to diagnose when you separate package discovery, repository state, transaction history, and cache state. Start with the least destructive command that proves what DNF can see.
Package Name Is Not Found
If DNF reports no match for a package, search by name first, then inspect enabled repositories:
search_term=vim
dnf search --name "$search_term"
dnf repo list --enabled
If the package belongs to a third-party source, enable the correct source for your Fedora release and retest with dnf info <package>. Multimedia and nonfree packages often require RPM Fusion rather than a random vendor repository.
Installed Command Is Missing
When a command is missing, check whether it exists in your current shell and then ask DNF which package provides it:
command_name=semanage
command -v "$command_name"
dnf provides "*/$command_name"
Install the provider package shown by DNF, then verify the command path again with command -v <command>.
config-manager Command Is Missing
DNF5 exposes config-manager as a command provider. Check for it first:
dnf config-manager --help
If the command is unavailable, install the provider and rerun the help command:
sudo dnf install 'dnf5-command(config-manager)'
dnf config-manager --help
Old DNF4 or YUM Command Fails
Older Fedora examples often use commands that DNF5 no longer treats as the preferred form. Replace them with the current syntax before troubleshooting unrelated causes.
| Old Form | Current Fedora Form | Why It Matters |
|---|---|---|
sudo yum install <package> | sudo dnf install <package> | Fedora uses DNF for package transactions. |
sudo dnf localinstall package.rpm | sudo dnf install ./package.rpm | DNF can install local RPM files directly with install. |
sudo dnf groupinstall "Development Tools" | sudo dnf group install <group-id> | Current Fedora uses the group command family. |
sudo dnf config-manager --add-repo URL | sudo dnf config-manager addrepo --from-repofile=URL | DNF5 config-manager uses command-style subcommands. |
sudo dnf config-manager --disable repo | sudo dnf config-manager setopt repo.enabled=0 | Repository enabled state is changed with DNF5 option setting syntax. |
Transaction Has Dependency Conflicts
Preview the transaction and read the proposed package changes before using conflict-resolution options:
sudo dnf upgrade --refresh --assumeno
If DNF proposes removals or replacements that you do not expect, check enabled repositories and recent history before confirming:
dnf repo list --all
dnf history list
Use --allowerasing only after the transaction preview shows removals you are willing to accept:
sudo dnf upgrade --refresh --allowerasing
RPM Database Looks Broken
RPM database problems are lower-level than normal DNF cache issues. Do not treat them as a routine dnf clean all problem. If DNF or RPM reports database corruption, use the dedicated recovery procedure to fix a broken RPM database on Fedora, then retest with rpm -qa and a simple DNF query.
Official Fedora and DNF Resources
Use official references when command behavior matters, especially around DNF5 syntax and release upgrades:
- Fedora DNF package manager quick reference
- DNF5 command reference
- DNF5 config-manager reference
- DNF5 system-upgrade reference
Conclusion
Fedora package work is safer when you query first, preview risky transactions, and reserve sudo for changes that modify packages, repositories, caches, or staged offline work. Keep this cheat sheet for daily terminal use; move to focused setup or release-upgrade guides when the task becomes scheduled updates, third-party repositories, or a full Fedora version upgrade.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><a href="https://example.com">link</a><blockquote>quote</blockquote>