Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

These 20 DNF commands cover package installation and removal, updates, repository discovery, cache maintenance, and transaction recovery. The examples below use DNF4-compatible syntax; check your distribution’s installed dnf --help or dnf5 --help and manual because available commands, defaults, and syntax can vary.

DNF manages packages on RPM-based distributions. In the examples, <package> means a package name, <term> a search phrase, <repo-id> a repository identifier, and <transaction-id> an ID shown by dnf history. Replace each placeholder with a real value; do not type the angle brackets.

Before running DNF commands: identify your version

DNF4 and DNF5 are not identical in every detail. Fedora Linux 41 made DNF5 the default for new installs and system upgrades, but DNF4 may remain installed. Other distributions can ship different versions, plugins, and defaults. The DNF5 documentation describes it as “the new version of DNF, a package manager for RPM-based Linux distributions.” See the DNF5 Package Management Utility documentation and its DNF4-to-DNF5 CLI changes when checking syntax.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The commands below use DNF4-style examples. Before confirming any operation that changes packages, read the proposed transaction: dependency resolution can add, remove, upgrade, or downgrade packages beyond the one named. Repository configuration also affects what DNF can install; the global configuration is typically /etc/dnf/dnf.conf, with repository files under /etc/yum.repos.d, though distributions can override settings. See the DNF configuration reference.

Install, remove, and update packages

1. Install a package

dnf install <package>

Installs the named package and any required dependencies from enabled repositories. Review the transaction summary and confirm that the package is coming from an expected repository before accepting.

2. Remove a package

dnf remove <package>

Removes the package. Packages that depend on it may also be removed, and under the default clean_requirements_on_remove behavior DNF may remove dependencies that are no longer needed. Inspect every proposed removal before proceeding; the setting and behavior can vary by system. See the DNF configuration reference.

3. Upgrade packages

dnf upgrade

Updates installed packages to the latest versions DNF can resolve from enabled repositories. Because this can change multiple packages, review the transaction and repository sources before confirming. Repository choice matters: Fedora’s DNF FAQ cautions that installing Rawhide packages on a stable Fedora release can produce less-tested package combinations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Check for available updates

dnf check-update

Checks whether enabled repositories offer updates without applying them. An exit code indicating that updates are available is not necessarily an execution failure; account for that behavior when using the command in scripts.

5. Apply security-filtered updates or inspect advisories

dnf updateinfo

Displays advisory information where supported and available. To request security-filtered updates, use dnf upgrade --security on versions that support it. This filtering depends on advisory metadata from repositories and on command support in the installed DNF generation; it is not a guarantee of a complete security audit. Consult your distribution’s documentation and the DNF5 command reference for version-specific support.

Find packages and inspect repositories

6. List enabled repositories

dnf repolist

Shows enabled repositories. To include disabled repositories in the listing, run dnf repolist --all. Use this before installing or upgrading if you need to verify which package sources are active.

7. Search package names and descriptions

dnf search <term>

Searches package names and descriptions for the supplied term. Use a distinctive word or phrase, then inspect likely matches with dnf info before choosing one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

8. Read package information

dnf info <package>

Displays package summary and description information, helping you distinguish similarly named packages before installation. The exact fields shown can depend on the DNF version and repository metadata.

9. List installed packages

dnf list --installed

Lists installed packages. DNF list modes can also show available or all packages; consult the installed version’s help for the precise modes and output available on your distribution.

10. Find which package provides a file or capability

dnf provides <file-or-capability>

Searches package metadata for a package that provides a command, file, or capability. For example, query a full file path when you need to identify which package supplies it.

11. Query packages in enabled repositories

dnf repoquery <package>

Queries repository-side package information for enabled repositories. It is useful when you want to inspect what repositories offer rather than query only the RPMs already installed on the system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Refresh or clear cached data

12. Refresh repository metadata

dnf makecache

Creates or refreshes the local metadata cache for enabled repositories. Use it when repository metadata may be stale; repositories may require network access for the refresh to complete.

13. Clear selected cache data

dnf clean <metadata|packages|all>

Removes the selected cached metadata, downloaded packages, or both, according to the argument and DNF version. Cleaning the cache does not remove the installed package set.

Review package transactions and recover carefully

14. List recorded transactions

dnf history

Lists package transactions recorded by DNF. What you can review depends on what was recorded and retained, so history may not provide a complete record of every change on a system.

15. Inspect a transaction

dnf history info <transaction-id>

Shows details for a recorded transaction. Use it to understand what changed before attempting a corrective action.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

16. Attempt to undo a transaction

dnf history undo <transaction-id>

Attempts an inverse operation for the selected recorded transaction. It is not a guaranteed rollback: the undo can be impossible if the current RPM database state, available packages, or dependencies prevent DNF from resolving it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Clean up or align installed packages

17. Remove unneeded dependency packages

dnf autoremove

Proposes removing packages that were installed as dependencies and are no longer needed. Check the full transaction carefully to make sure it will not remove software your system still relies on.

18. Synchronize packages with enabled repositories

dnf distro-sync

Synchronizes installed package versions with versions available in enabled repositories. It can upgrade or downgrade packages, so review the proposed changes and repository set before confirming.

19. Reinstall a package

dnf reinstall <package>

Reinstalls a package when it is installed and the same package is available from a configured repository. If the package is unavailable from enabled sources, DNF cannot reinstall it using this command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

20. Downgrade a package

dnf downgrade <package>

Moves a package to an older version available from configured repositories when dependency resolution permits. The desired version must be available, and related package constraints can prevent the downgrade.

Keep DNF4 and DNF5 history in context

Fedora Linux 41 made DNF5 the default for new installs and system upgrades. DNF4 and DNF5 can share an RPM database, but they use different state files and do not share transaction histories concurrently. Package install reasons may also appear as user-installed when viewed across versions. Avoid switching between the tools as though their history and state were identical; see the DNF5 migration and CLI changes documentation for details.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.