A package change can bring several RPMs along with it. On Fedora, Red Hat Enterprise Linux (RHEL), and CentOS Stream, DNF records those changes together so you can undo a single transaction by its history ID.
Undoing an installation removes the packages it added. Undoing a removal or upgrade depends on DNF still being able to obtain the package versions it needs.
Later package changes can affect whether DNF can reverse the selected transaction. The proposed undo shows what DNF would change on the system as it stands now.
Steps to undo a DNF transaction:
- Find the original transaction ID by its command and date in DNF history.
$ dnf history list
The Fedora example uses transaction 3, which installed tree.
- Inspect the package changes using your transaction ID in place of 3.
$ dnf history info 3 Transaction ID : 3 ##### snipped ##### Status : Ok ##### snipped ##### Packages altered: Action Package Reason Repository Install tree-0:2.3.1-2.fc45.aarch64 User fedora
A successful entry shows Status: Ok on DNF5 or Return-Code: Success on DNF4. If the entry failed or lists the wrong packages, stop before running the undo.
- Run the undo using your transaction ID in place of 3.
$ sudo dnf --setopt=assumeyes=False history undo 3 ##### snipped ##### Package Arch Version Repository Size Removing: tree aarch64 0:2.3.1-2.fc45 fedora 169.1 KiB Transaction Summary: Removing: 1 package ##### snipped #####
The
--setopt=assumeyes=Falseoption keeps automatic approval off. DNF shows the proposed changes before asking for confirmation. If DNF reports a missing build or a dependency conflict, stop there. - Approve the listed changes with y at DNF's prompt only if they reverse the selected transaction.
Answer N if the plan removes packages you still need, changes packages outside the original transaction, or downgrades RHEL system packages such as kernel, glibc, or selinux-policy-*. Red Hat does not support undoing those upgrades through DNF history.
- Compare the installed RPM records with the approved summary, replacing tree with each affected package name.
$ rpm -q --qf '%{NAME} %{EPOCHNUM}:%{VERSION}-%{RELEASE}.%{ARCH}\n' tree package tree is not installedThe query shows the name, epoch, version, release, and architecture. A removed record should be absent. An older kernel can still be installed after undoing a kernel install. A restored record should match the planned identity. For example, Fedora's restored tree record reads tree 0:2.3.1-2.fc45.aarch64. RPM displays epoch 0 when none is set.