DNF is the default Fedora package manager for installing, updating, and removing RPM packages. This guide covers practical DNF usage (search, install, remove, upgrade), how to exclude or lock package versions, enabling automatic updates, and options for trying or switching to DNF5. Useful for beginners and intermediate users, the steps follow a logical sequence: prerequisites, installation, setup, verification, and troubleshooting. The guide also highlights what to expect as Fedora moves toward DNF5.
Prerequisites
- You need a Fedora system with a user that has sudo privileges.
- Network access to Fedora repositories.
- Familiarity with a shell (bash, zsh, or fish).
Quick DNF basics: search, install, remove
These commands use DNF's core functions. Each example is followed by a realistic sample output and a short explanation.
Search for a package
dnf search nano
Last metadata expiration check: 0:01:23 ago on Thu 02 Mar 2026 10:15:03 AM UTC. ===================================== Name Matched: nano ===================================== nano.x86_64 : Small, friendly text editor inspired by Pico nano-doc.noarch : Documentation for GNU nano
What this does: dnf search queries enabled repositories for packages whose name or summary match the term. Use it to discover package names before installing.
Install a package
sudo dnf install nano -y
Last metadata expiration check: 0:00:55 ago on Thu 02 Mar 2026 10:16:26 AM UTC. Dependencies resolved. ================================================================== Package Arch Version Repository Size ================================================================== Installing: nano x86_64 5.9-1.fc36 fedora 1.5 M Transaction Summary ================================================================== Install 1 Package Total download size: 1.5 M Installed size: 4.1 M Downloading Packages: (1/1): nano-5.9-1.fc36.x86_64.rpm 1.5 MB/s | 1.5 MB 00:01 ------------------------------------------------------------------ Total 2.1 MB/s | 1.5 MB 00:01 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : nano-5.9-1.fc36.x86_64 1/1 Running scriptlet: nano-5.9-1.fc36.x86_64 1/1 Verifying : nano-5.9-1.fc36.x86_64 1/1 Installed: nano.x86_64 5.9-1.fc36 Complete!
What this does: sudo runs the command with administrative privileges (required to modify system packages). dnf install resolves dependencies and installs the package. The -y flag automatically answers “yes” to prompts for non-interactive installs.
Remove a package
sudo dnf remove nano -y
Last metadata expiration check: 0:00:14 ago on Thu 02 Mar 2026 10:18:40 AM UTC. Dependencies resolved. ================================================================== Package Arch Version Repository Size ================================================================== Removing: nano x86_64 5.9-1.fc36 @fedora 4.1 M Transaction Summary ================================================================== Remove 1 Package Installed size: 4.1 M Running transaction Preparing : 1/1 Erasing : nano-5.9-1.fc36.x86_64 1/1 Running scriptlet: nano-5.9-1.fc36.x86_64 1/1 Verifying : nano-5.9-1.fc36.x86_64 1/1 Removed: nano.x86_64 5.9-1.fc36 Complete!
What this does: dnf remove uninstalls the package and (by default) will not remove orphaned dependencies unless you run dnf autoremove.
Keeping Fedora up to date
Check for available updates
sudo dnf check-update
Last metadata expiration check: 0:02:10 ago on Thu 02 Mar 2026 10:20:50 AM UTC. bash.x86_64 5.2-4.fc36 updates kernel.x86_64 6.6.8-300.fc36 updates firefox.x86_64 120.0.1-1.fc36 updates
What this does: dnf check-update queries repositories and reports available package upgrades without downloading or applying them — useful when planning updates.
Upgrade the system (and exclude packages)
sudo dnf upgrade --exclude=firefox -y
Last metadata expiration check: 0:00:40 ago on Thu 02 Mar 2026 10:22:30 AM UTC. Excluding Packages: firefox Dependencies resolved. ================================================================== Package Arch Version Repository Size ================================================================== Upgrading: kernel x86_64 6.6.8-300.fc36 updates 78 M Transaction Summary ================================================================== Upgrade 1 Package Total download size: 78 M Downloading Packages: (1/1): kernel-6.6.8-300.fc36.x86_64.rpm 25 MB/s | 78 MB 00:03 ------------------------------------------------------------------ Total 24 MB/s | 78 MB 00:03 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Upgrading : kernel-6.6.8-300.fc36.x86_64 1/1 Verifying : kernel-6.6.8-300.fc36.x86_64 1/1 Upgraded: kernel.x86_64 6.6.8-300.fc36 Complete!
What this does: dnf upgrade downloads and applies package updates. Use –exclude=packagename to skip a package (handy when a particular update causes regressions). You can also set exclusions permanently in /etc/dnf/dnf.conf (see the Excluding Packages section below).
Exclude packages permanently or per-repo
If a package update causes issues, exclude it:
Temporary, per-command exclude
sudo dnf upgrade --exclude=packagename
Last metadata expiration check: 0:00:20 ago on Thu 02 Mar 2026 10:25:00 AM UTC. Excluding Packages: packagename No packages marked for update.
This shows the exclude in action: DNF skips the named package during that transaction.
Permanent exclude via config file
Edit /etc/dnf/dnf.conf and add:
excludepkgs=packagename*
After saving the file, DNF will ignore matching packages across commands. To temporarily override the config exclusion for one command, use:
sudo dnf upgrade --disableexcludes=all
Last metadata expiration check: 0:00:10 ago on Thu 02 Mar 2026 10:26:10 AM UTC. Dependencies resolved. ... (proceeds with upgrade including previously excluded packages)
Why: Global excludes are useful when a GUI updater doesn't let you choose packages to skip; –disableexcludes temporarily lifts those rules when needed.
Locking package versions: use the Versionlock plugin
The versionlock plugin prevents DNF from upgrading selected packages. Install and use it as follows.
Install the plugin
sudo dnf install 'dnf-command(versionlock)' -y
Last metadata expiration check: 0:00:05 ago on Thu 02 Mar 2026 10:27:05 AM UTC. Dependencies resolved. ================================================================== Package Arch Version Repository ================================================================== Installing: dnf-plugins-core noarch 4.0.16-1.fc36 fedora Transaction Summary ================================================================== Install 1 Package Total download size: 120 k Installed size: 650 k Downloading Packages: (1/1): dnf-plugins-core-4.0.16-1.fc36.noarch.rpm 250 kB/s | 120 kB 00:00 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : dnf-plugins-core-4.0.16-1.fc36.noarch 1/1 Verifying : dnf-plugins-core-4.0.16-1.fc36.noarch 1/1 Installed: dnf-plugins-core.noarch 4.0.16-1.fc36 Complete!
What this does: Installs the versionlock command (part of dnf-plugins-core) that lets you pin package versions.
Lock and list versions
sudo dnf versionlock add firefox
Added: 1:firefox-120.0-1.fc36.x86_64 to versionlock list
What this does: Pins the currently installed version of firefox, preventing upgrades of that package.
sudo dnf versionlock list
1:firefox-120.0-1.fc36.x86_64
This shows all locked entries. Remove the lock with sudo dnf versionlock delete firefox or clear all locks with sudo dnf versionlock clear.
Automatic updates
Fedora provides dnf-automatic to download and optionally install updates automatically and send logs by email. Install and configure it if you want unattended updates on a server:
sudo dnf install dnf-automatic -y
Last metadata expiration check: 0:00:03 ago on Thu 02 Mar 2026 10:29:02 AM UTC. Dependencies resolved. ================================================================== Package Arch Version Repository ================================================================== Installing: dnf-automatic noarch 5.0.1-1.fc36 updates Transaction Summary ================================================================== Install 1 Package Complete!
After installing, configure /etc/dnf/automatic.conf and enable the timer with systemctl enable –now dnf-automatic.timer to start automatic checks and installs. (Adjust email logging as needed.)
Trying or switching to DNF5
DNF5 is a C++ rewrite of DNF (sometimes called dnf5). Fedora has been migrating tooling and builds to DNF5; it offers similar user commands but introduces some CLI and API changes. If you want to try DNF5 alongside the system DNF, install and optionally alias it. Note: in production or scripted environments, test carefully — DNF5 dropped some single-word group aliases and some plugin parity is still being completed (see the DNF5 changes documentation).
Install DNF5 (try side-by-side)
sudo dnf install dnf5 -y
Last metadata expiration check: 0:00:12 ago on Thu 02 Mar 2026 10:30:30 AM UTC. Dependencies resolved. ================================================================== Package Arch Version Repository Size ================================================================== Installing: dnf5 x86_64 5.2.0-1.fc40 updates 6.2 M Transaction Summary ================================================================== Install 1 Package Complete!
What this does: Installs the dnf5 binary alongside the system dnf. Using dnf5 lets you test behavior without replacing the system DNF.
Optional: alias dnf to dnf5 in bash/zsh
To use dnf5 with the familiar dnf command in your interactive shell, add an alias to your shell config:
echo 'alias dnf="dnf5"' >> ~/.bashrc
(No output on success; the alias is appended to ~/.bashrc.)
Important: shells invoked by sudo do not expand user aliases. To have sudo dnf run dnf5, also add:
echo 'alias sudo="sudo "' >> ~/.bashrc
(This makes sudo preserve aliases in interactive use by creating a whitespace-protected alias.)
Alternate: explicitly run dnf5 (recommended for scripts), or adjust the system PATH carefully. For the fish shell, add a small wrapper function:
function sudo
if test "$argv[1]" = "dnf"
set argv[1] dnf5
end
command sudo $argv
endPlace that block into ~/.config/fish/config.fish to transparently translate sudo dnf → sudo dnf5 for interactive fish sessions.
Important differences & compatibility notes
- DNF5 aims for command compatibility, but some options and aliases were removed or renamed (for example, single-word group commands such as groupinstall may be missing). Check the dnf5 docs for CLI differences.
- Some plugins for DNF4 are still being ported to DNF5. Confirm plugin availability before relying on them for automation.
- There were API/ABI bumps during DNF5 development—tools that integrate with libdnf may need porting. If you maintain tooling, review the DNF5 API changes before switching system-wide.
System upgrades
Fedora system upgrades can be performed with DNF and with the DNF system-upgrade plugin. While DNF5 aims to provide similar system-upgrade commands, Fedora may use DNF4 for certain upgrade paths depending on release timelines. Always follow the Fedora release notes and upgrade documentation for the recommended upgrade method for your target release.
Verification
After making changes (installing packages, enabling automatic updates, or trying DNF5), verify:
- Installed package list:
dnf list installed nano
Last metadata expiration check: 0:00:08 ago on Thu 02 Mar 2026 10:33:12 AM UTC. Error: No matching Packages to list
Explanation: This output indicates the package isn't installed; for installed packages you'll see the package and version.
- Active timers for auto updates:
systemctl status dnf-automatic.timer
● dnf-automatic.timer - Run automatic dnf daily Loaded: loaded (/usr/lib/systemd/system/dnf-automatic.timer; enabled; vendor preset: enabled) Active: active (waiting) since Thu 2026-03-02 10:31:00 UTC; 2min ago Trigger: Fri 2026-03-03 00:00:00 UTC (in 13h)Explanation: Confirms the automatic update timer is enabled and scheduled.
- Test DNF5 behavior without changing system DNF:
dnf5 check-update
Last metadata expiration check: 0:00:50 ago on Thu 02 Mar 2026 10:34:22 AM UTC. (no updates available)
Explanation: Running dnf5 directly verifies it can reach repos and report updates.
Troubleshooting & tips
Broken transactions or metadata issues
sudo dnf clean all
Cleaning repos: fedora updates Cleaning up everything
Then re-run sudo dnf check-update. dnf clean all clears cached metadata and packages to fix corruption or stale metadata problems.
Resolve dependency problems using allowerasing
If an upgrade requires removing conflicting packages, DNF can allow erasure:
sudo dnf upgrade --allowerasing -y
Last metadata expiration check: 0:00:20 ago on Thu 02 Mar 2026 10:36:55 AM UTC. Dependencies resolved. Note: Uninstalling conflicting packages to proceed...
Use this when dependency resolution requires removing packages; review the transaction carefully before accepting.
Plugins not available in DNF5
DNF5 is still catching up on plugin parity. If a plugin you rely on is missing in DNF5, either continue using system DNF for that workflow or test alternatives. Track plugin status at the DNF5 project issue tracker if you need specific functionality.
Summary and next steps
DNF remains the core Fedora package manager for installing, updating, and removing packages. Use dnf install, dnf remove, and dnf upgrade for standard workflows, combine –exclude or versionlock to control updates, and consider dnf-automatic for unattended updates. If you want to experiment with the upcoming DNF5, install dnf5 side-by-side and test it thoroughly before replacing system tooling; be especially careful with scripts and plugins because some command aliases and plugin support have changed.
Useful references
- DNF command reference: https://dnf.readthedocs.io/en/latest/command_ref.html
- DNF5 changes & compatibility notes: https://dnf5.readthedocs.io/
- Fedora docs: package management and upgrades
Conclusion
DNF provides robust package management on Fedora. This guide explained how to search, install, remove, upgrade, exclude, and lock package versions, plus how to enable automatic updates and safely test DNF5. Whether you stick with the stable DNF or evaluate DNF5, test workflows and plugins before making system-wide switches to avoid surprises.
