This happens more often than most Linux administrators would like to admit.

Maybe a new Nginx release introduced a default configuration change that broke your virtual hosts.

A Python library update changed an API that your internal scripts rely on.

Or perhaps a kernel update no longer works with a third-party driver.

From DNF’s point of view, everything installed successfully, but that doesn’t always mean your applications will continue to work as expected.

Downgrading a package on RHEL-based distributions is easy when it’s an independent package, but things become more challenging when other packages depend on the newer version, because DNF may also need to downgrade related dependencies to keep the system consistent.

In this guide, you’ll learn how to check which package versions are available, safely downgrade a package, prevent it from being updated again, recover an older package from the local RPM cache, and even roll back an entire DNF transaction if an update caused problems.

Before you start downgrading packages, it’s useful to understand what DNF does behind the scenes.

Every time you install, update, remove, or downgrade a package, DNF records the operation as a transaction in its history database.

This history makes it possible to review previous changes and, in many cases, roll back an entire transaction instead of manually fixing individual packages.

When you run a package downgrade, DNF doesn’t simply replace the newer package with an older one.

It first checks whether the older version is compatible with the rest of the packages currently installed on your system.

If another package depends on the newer version, DNF will detect the conflict depending on the situation, it may:

That’s why it’s worth answering two questions before running a downgrade:

Taking a minute to check these first can save you from creating even more dependency problems later.

Before downgrading a package, check which version is currently installed and whether the older version is still available in your enabled repositories.

To list all available versions of a package, run:

Example output:

The Installed Packages section shows the version currently installed on your system.

The Available Packages section lists every version that your enabled repositories currently provide.

If the version you want appears here, you can downgrade to it.

If it doesn’t, the repository no longer carries that package version.

Don’t worry, we’ll cover how to recover older packages from the local RPM cache later in this guide.

If you want more information about the installed package, including the repository it came from, use:

Example output:

Pay attention to the Version, Release, and Epoch fields.

Together, they uniquely identify the package version.

If you need to downgrade to a specific release, you’ll use this version information in the downgrade command.

If you simply want to go back to the previous version of a package, use the dnf downgrade command:

Example output:

The sudo command runs DNF with administrator privileges, which are required when installing, removing, or downgrading system packages.

The dnf downgrade command automatically selects the highest available version that is older than the one currently installed.

Review the transaction summary, and if everything looks correct, press y to continue.

Once the downgrade is complete, verify that the expected version is installed:

Example output:

If the version shown matches the one you expected, the downgrade was successful.

If you need to downgrade to a version that’s more than one release behind, specify the package name followed by the target version:

Example output:

The transaction output is easy to follow:

After the transaction finishes, verify the installed version:

If the output shows the version you requested, the downgrade was successful.

After downgrading a package, the next dnf update will try to install the latest available version again.

If you want to keep the package at its current version, use the versionlock plugin.

Once the plugin is available, lock the current version of the package:

To see all locked packages, run:

Example output:

The .* at the end is a wildcard that matches all architectures of that package version.

With the lock in place, future dnf update commands will skip nginx, leaving it at the version you’ve pinned.

When you’re ready to receive updates again, remove the lock:

Sometimes the version you need is no longer available in your enabled repositories.

It may have been replaced by a newer release, removed from the repository, or you’re working on a system without internet access.

If you still have the older RPM file, you can install it directly.

First, check whether the package is still available in DNF’s local cache:

Example output:

If you find the version you need, install it by specifying the full path to the RPM file:

Example output:

Even though you’re installing an RPM file manually, DNF recognizes that the package is older than the installed version and performs a downgrade instead of a normal installation.

It also checks dependencies just as it would when installing from a repository.

If you downloaded the RPM from another system or an external source, verify its signature before installing it:

If a system update broke more than one package, you don’t have to downgrade each package individually.

DNF keeps a history of every transaction, making it possible to undo an entire update with a single command.

First, view your recent DNF transactions:

Example output:

Each transaction has a unique ID.

You’ll use this ID if you want to inspect or undo a specific operation.

To see exactly what changed during a transaction, run:

Example output:

This output shows that transaction 12 upgraded nginx from version 1.24.0 to 1.26.2.

To undo that transaction, run:

After you confirm the transaction, DNF restores the packages to the versions they had before transaction 12 was applied.

If you simply want to undo the most recent DNF transaction, you don’t need to look up its ID:

If you end up in a state where dnf is refusing to install or update anything because of broken dependencies, run a consistency check first:

Example output:

This output tells you exactly what’s broken and why.

In this case, nginx was downgraded but nginx-filesystem wasn’t, so the version requirement is unmet.

Fix it by downgrading the dependency too:

Run dnf check again to confirm nothing else is broken:

No output means the RPM database is consistent and all dependencies are satisfied.

Have you used dnf history undo to recover from a bad update, or found a faster way to track down the right version when the repo no longer carries it? Share it in the comments below.

Try uutils-coreutils: Rust Alternative to GNU Coreutils

5 Ways to Check Remote Port Connectivity in Linux

How to Resize ext4 Partitions and Filesystems in Linux

at Command: Schedule One-Time Linux Tasks Without Cron

20 Must-Know Linux Commands for System Administrators

How to Stop Linux Processes from Using Excessive CPU and RAM

BCC – Tracing Tools for Linux IO, Networking, Monitoring, and More

Cpustat – Monitors CPU Utilization by Running Processes in Linux

How to Install Zabbix on RHEL/CentOS and Debian/Ubuntu – Part 1

How To Install Pandora FMS Monitoring Tool in Ubuntu 18.04

How to Install Cacti with Cacti-Spine in Debian and Ubuntu

Amplify – NGINX Monitoring Made Easy

Fun in Linux Terminal – Play with Word and Character Counts

Learn Why ‘less’ is Faster Than ‘more’ Command for Effective File Navigation

How to Install and Run Multiple glibc Libraries in Linux

How to Copy File Permissions and Ownership to Another File in Linux

4 Ways to Check Plugged USB Device Name in Linux

How to Convert From RPM to DEB and DEB to RPM Package Using Alien

16 Free and Open Source Video Players for Linux in 2024

8 Best Open Source Web Servers in 2024

6 Best Modern Linux ‘init’ Systems (1992-2025)

12 Best Java IDE’s for Linux Developers

5 CLI Tools for Downloading Files and Browsing Internet in Terminal

8 Best Mail Transfer Agents (MTA’s) for Linux

**📚 Original Source:**
[How to Downgrade and Lock Packages With dnf in RHEL Systems](https://www.tecmint.com/downgrade-package-dnf-command/)

About The Author