A package update can introduce a regression that makes the current build worth keeping. On Fedora and RHEL-family systems, DNF versionlock can pin a package to its installed version while letting unrelated packages receive updates.
DNF applies the lock when it resolves a transaction. A package search can still show a newer build even when DNF would skip that build during an upgrade.
Fedora's DNF5 includes versionlock. RHEL, CentOS Stream, and other systems that use DNF4 provide the same subcommand through a separate plugin.
Steps to lock a package version with DNF:
- Check the installed version of your package, replacing vim-minimal with its name wherever it appears.
$ rpm -q --qf \ '%{NAME} %{EPOCHNUM}:%{VERSION}-%{RELEASE}.%{ARCH}\n' \ vim-minimal vim-minimal 2:9.2.1202-1.fc45.aarch64If RPM reports that the package is absent or lists more than one installed build, stop. Install-only packages such as kernels can have several builds installed.
- Install the versionlock plugin if your system uses DNF4.
$ sudo dnf install \ python3-dnf-plugin-versionlock
On DNF4, answer y if the transaction lists the plugin from an expected distribution repository. On DNF5, skip the installation.
- Check the current versionlock entries for your package.
$ sudo dnf versionlock list
Continue only if the command succeeds and the list contains neither an entry for your package name nor a wildcard entry that matches it.
- Preview an upgrade for your package without applying it.
$ sudo dnf upgrade \ --assumeno vim-minimal
The --assumeno option declines the transaction. A newer version under Upgrading gives you a result to compare after locking.
- Lock your package to its installed version.
The lock also skips security fixes delivered in newer versions of the package. Keep it only while you need the installed build.
$ sudo dnf versionlock \ add vim-minimal
- Compare the stored lock against the installed build from the RPM query.
$ sudo dnf versionlock list ##### snipped ##### Package name: vim-minimal evr = 2:9.2.1202-1.fc45
The package name, epoch, version, and release must match the RPM query. Here the epoch, version, and release are 2:9.2.1202-1.fc45. On DNF4, these fields appear on the same line as the package name.
- Repeat the upgrade preview for your package with the lock in place.
$ sudo dnf upgrade \ --assumeno vim-minimal ##### snipped ##### Nothing to do.
If the earlier preview offered an upgrade, Nothing to do. confirms DNF now skips it when both previews resolve with the same repositories available. A skipped repository or resolution error makes the comparison inconclusive. If neither preview offers an upgrade, the saved entry confirms the lock and you can repeat the preview when a newer build is available. A proposed upgrade at this step means a different build is still eligible.
When you are ready to receive updates for the package again, sudo dnf versionlock delete vim-minimal removes the rule you added for that package.