Fedora DNF Command Line Cheat Sheet

Fedora package commands changed with DNF5. This cheat sheet gives you current dnf patterns for upgrades, searches, installs, removals, repositories, groups, history, offline transactions, and common fixes.

PublishedAuthorJoshua JamesRead time10 minGuide typeFedora

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.

TaskCommandWhat It Does
Check Fedora releasecat /etc/fedora-releasePrints the Fedora edition and release number.
Check DNF versiondnf --versionShows whether the command is backed by DNF5 and which library versions are installed.
Refresh metadata and upgradesudo dnf upgrade --refreshRefreshes enabled repositories and upgrades installed packages.
Check available upgradesdnf check-upgradeLists packages with newer candidates without applying the transaction.
Search package namesdnf search --name <term>Searches package names for a short term.
Show package detailsdnf info <package>Displays package version, repository, size, summary, and description.
Find the package for a commanddnf provides '*/<command>'Finds packages that provide a matching executable or file path.
Install a packagesudo dnf install <package>Installs the package and required dependencies after transaction review.
Preview an installsudo dnf install --assumeno <package>Shows the planned transaction and exits without installing anything.
Remove a packagesudo dnf remove <package>Removes the package and any dependency removals included in the reviewed transaction.
List enabled repositoriesdnf repo list --enabledShows repositories currently used for package metadata and transactions.
List all repositoriesdnf repo list --allShows enabled and disabled repositories with their IDs.
List package groupsdnf group list --hiddenLists visible and hidden package groups, including group IDs used by DNF5.
Review transaction historydnf history listShows recent DNF transactions and their IDs.
Inspect one transactiondnf history info <id>Prints package changes made by a specific transaction.
Clean metadata cachesudo dnf clean metadataRemoves 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.

TaskCommandWhat It Does
Upgrade installed packagessudo dnf upgrade --refreshRefreshes metadata and applies available package upgrades after confirmation.
Check pending upgradesdnf check-upgradeLists packages that have available upgrades.
Upgrade one packagesudo dnf upgrade <package>Upgrades a named installed package when a newer candidate exists.
Apply minimal security fixes when availablesudo dnf upgrade --minimal --securityPrefers the smallest available updates that satisfy security advisories.
Synchronize installed packages with enabled repositoriessudo dnf distro-syncAligns installed package versions with repository candidates, including downgrades when needed.
Review automatic update setupsystemctl 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.

TaskCommandWhat It Does
Search package namesdnf search --name <term>Finds packages with matching names.
Search names and descriptionsdnf search <term>Searches broader package metadata when the exact package name is unknown.
Show package detailsdnf info <package>Shows package metadata, repository, license, and description.
Show installed package detailsdnf info --installed <package>Limits package information to installed packages.
List installed packagesdnf list --installedLists packages installed on the system.
List available packagesdnf list --availableLists packages available from enabled repositories.
Show available versionsdnf list --showduplicates <package>Shows multiple available versions when repositories expose them.
Find a package by command namednf provides '*/semanage'Finds packages that ship a matching executable name.
Find the owner of an installed filerpm -qf /usr/bin/dnfShows which installed RPM owns a file already present on the system.
Verify an installed packagerpm -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.

TaskCommandWhat It Does
Install one packagesudo dnf install <package>Installs the named package and required dependencies.
Install several packagessudo dnf install <package1> <package2>Installs multiple packages in one reviewed transaction.
Preview an installsudo dnf install --assumeno <package>Calculates the transaction and exits without changing packages.
Install a local RPM filesudo dnf install ./package.rpmInstalls a local RPM while resolving dependencies from enabled repositories.
Download packages without installingsudo dnf install --downloadonly <package>Downloads packages and dependencies for the transaction without applying it.
Reinstall a packagesudo dnf reinstall <package>Reinstalls package-owned files from the repository copy.
Remove a packagesudo dnf remove <package>Removes the package and reviewed dependency removals.
Remove without automatic dependency cleanupsudo dnf remove --no-autoremove <package>Removes the named package while leaving automatically installed dependencies in place.
Remove unused dependenciessudo dnf autoremoveRemoves packages marked as automatically installed and no longer required.
Prune old install-only packagessudo dnf remove --oldinstallonly --limit=2Removes 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.

TaskCommandWhat It Does
List enabled repositoriesdnf repo list --enabledShows repositories currently active for package operations.
List disabled and enabled repositoriesdnf repo list --allShows every configured repository and its enabled state.
Inspect a repositorydnf repo info <repo-id>Shows repository details for a specific repository ID.
Check config-manager availabilitydnf config-manager --helpConfirms whether the DNF5 config-manager command is available.
Install config-manager providersudo dnf install 'dnf5-command(config-manager)'Installs the DNF5 command provider when config-manager is missing.
Add a repository filesudo dnf config-manager addrepo --from-repofile=https://example.com/example.repoAdds a repository from a vendor-provided .repo file URL.
Disable a repositorysudo dnf config-manager setopt <repo-id>.enabled=0Disables the repository by setting its enabled option to false.
Enable a repositorysudo dnf config-manager setopt <repo-id>.enabled=1Enables the repository by setting its enabled option to true.
Verify repository statednf repo list --allConfirms 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.

TaskCommandWhat It Does
List visible groupsdnf group listShows standard visible package groups.
List hidden groups toodnf group list --hiddenIncludes hidden groups and IDs that may not appear in the default list.
Inspect a groupdnf group info <group-id>Shows mandatory, default, and optional packages for the group.
Install a groupsudo dnf group install <group-id>Installs packages selected by the group definition.
Upgrade a groupsudo dnf group upgrade <group-id>Applies group changes and upgrades installed group packages.
Remove a groupsudo 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.

TaskCommandWhat It Does
List recent transactionsdnf history listShows transaction IDs, dates, actions, and package counts.
Inspect one transactiondnf history info <id>Shows the packages installed, upgraded, removed, or downgraded in a transaction.
Undo one transactionsudo dnf history undo <id>Attempts to reverse all actions from the selected transaction.
Redo one transactionsudo dnf history redo <id>Attempts to repeat all actions from the selected transaction.
Rollback after an IDsudo 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.

TaskCommandWhat It Does
Check filesystem spacedf -h /Shows used and available space on the root filesystem.
Estimate DNF cache sizesudo du -sh /var/cache/dnfShows the approximate DNF cache directory size.
Clean metadatasudo dnf clean metadataRemoves cached repository metadata.
Clean downloaded packagessudo dnf clean packagesRemoves cached package files.
Clean all DNF cache typessudo dnf clean allRemoves metadata, packages, and other cached DNF data.
Expire metadatasudo dnf clean expire-cacheMarks 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.

TaskCommandWhat It Does
Prepare an offline upgradesudo dnf upgrade --refresh --offlineDownloads and stores an upgrade transaction for offline execution.
Prepare an offline installsudo dnf install --offline <package>Stores an install transaction to apply in the offline environment.
Show offline transaction statussudo dnf offline statusReports whether an offline transaction is queued.
Show offline transaction logssudo dnf offline logDisplays logs from completed offline transactions.
Clean a queued offline transactionsudo dnf offline cleanRemoves stored offline transaction data and cached package files.
Start a queued offline transactionsudo dnf offline rebootReboots into the offline transaction environment after a transaction has been prepared.
Check release upgrade commandsdnf system-upgrade --helpShows available release upgrade subcommands.
Download a release upgrade transactionsudo 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 upgradesudo dnf system-upgrade rebootStarts the staged Fedora release upgrade transaction.
Clean staged release upgrade datasudo dnf system-upgrade cleanRemoves 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 FormCurrent Fedora FormWhy It Matters
sudo yum install <package>sudo dnf install <package>Fedora uses DNF for package transactions.
sudo dnf localinstall package.rpmsudo dnf install ./package.rpmDNF 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 URLsudo dnf config-manager addrepo --from-repofile=URLDNF5 config-manager uses command-style subcommands.
sudo dnf config-manager --disable reposudo dnf config-manager setopt repo.enabled=0Repository 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:

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.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="https://example.com">link</a> link
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: