Moving from dnf to dnf5: the practical differences
Why this migration deserves its own page
Section titled “Why this migration deserves its own page”The dnf command on Fedora has changed implementation underneath. Day-to-day installs and removals feel the same, but plugins, scripts and some subcommand syntax change. The cost of migration is not the number of commands; it is how many “judgements written against the old output” have accumulated in your automation. This page follows the order “confirm, then check, then rewrite”.
First, confirm whether you are on dnf4 or dnf5
Section titled “First, confirm whether you are on dnf4 or dnf5”Fedora 41 and later default to DNF5; the DNF5 command reference is maintained separately at dnf5.readthedocs.io, not in the Fedora Quick Docs.
So the first migration step is not editing scripts but recording the baseline:
dnf --version # shows the implementation and version behind dnfCommand and output changes: check against the official docs
Section titled “Command and output changes: check against the official docs”The official Quick Docs provide Using the DNF software package manager as the dnf usage baseline, plus APT command equivalents on Fedora with DNF for people coming from another habit. The baseline documents the standard form of each subcommand (for example the dnf versionlock add / delete / list / clear group); during migration treat it as the first reference for “how do I do the same thing in the new environment”, not something to change from memory.
The official dnf5 command reference lists commands one by one, covering Advisory / Autoremove / Check / Check-Upgrade / Clean through to Swap / System-Upgrade / Versionlock and many more. That list is your script checklist:
| Action in your script | What to confirm during migration |
|---|---|
| Install, remove, upgrade | whether Install / Remove / Upgrade / Downgrade arguments and output still fit your parsing |
| Transactions and audit | whether History / Do / Replay / Offline (offline transactions) still follow the same path |
| Repositories and metadata | argument changes in Repo / Repoquery / Makecache / Clean |
| Automated checks | return values and output of decision-type subcommands such as Check / Check-Upgrade / Advisory |
Rewriting common scripts
Section titled “Rewriting common scripts”Beyond commands, what really decides the migration effort is script structure. Three rules:
- Consolidate dnf calls into one layer: put every
dnfcall behind one wrapper function or variable, so migration touches one place instead of grepping across dozens of scripts. - Do not parse human-readable output: base decisions on exit codes and explicit subcommands. Output differences between the two implementations are documented in Changes between DNF and DNF5 — your regex is not more authoritative than that.
- Run it once on the target release first: verify on an isolated environment at the target release; do not finish on F44 and assume F40 will work.
Plugins and extension points: where migration hurts most
Section titled “Plugins and extension points: where migration hurts most”The official dnf5 docs site has separate chapters for Tutorial: Writing Plugins, LIBDNF5 Plugins, Tutorial: API changes between DNF and DNF5 and Tutorial: Language Bindings — plugins and the API layer are where the two implementations differ most, and anything that depends on a plugin needs individual confirmation.
Constraints on the system Python, packaging and coexistence follow the Python chapter of the official Packaging Guidelines; do not stuff dependencies into the system Python with pip to restore functionality. Anything in your automation that reaches into the package manager at the Python level should be re-evaluated against that guide before migrating: if it can run in an isolated environment, put it in the isolation approach described in Fedora toolchain and multiple versions, not into the system Python.
What to confirm before rolling back to dnf4
Section titled “What to confirm before rolling back to dnf4”Rolling back is not a single command. Confirm three things first:
- Which layer you are rolling back: just the syntax of one subcommand, or the whole package manager implementation? The former is solved by rewriting scripts; only the latter is an implementation swap.
- What the rollback takes with it: system upgrades, offline transactions and plugins come from different sources across the two implementations (see Upgrade between Fedora releases); swapping the implementation swaps all of their backends at once.
- The official position on changes and migration: defer to Changes between DNF and DNF5 and Migrating from DNF to DNF5 on the dnf5 docs site.
Related pages
Section titled “Related pages”-
Module streams (retired) — why dnf5 has no module install
-
Cheat sheet — one-page F45 commands and the dnf4→dnf5 difference table
-
Fedora repositories and dnf5 — addrepo / setopt syntax and third-party sources
-
Upgrade between Fedora releases — where the upgrade path comes from in each implementation
-
Fedora toolchain and multiple versions — isolation without touching the system Python
-
Isolated development with Toolbox — verify scripts against a target release
-
Official: DNF5 Commands, Using the DNF software package manager, Python Packaging Guidelines