Ever found yourself in a situation where the system starts conflicting right after installing a few experimental packages? Even worse, after a sudo dnf upgrade command, the NVIDIA driver suddenly “drops dead,” leaving you with a black screen. Instead of panicking and reinstalling everything or manually removing each package, long-time Fedora users often turn to dnf history — an incredibly useful tool that helps you turn back time.
After using Fedora as my daily driver for two years, I’ve found that fast package updates are a plus, but they can occasionally break your workflow. In those moments, dnf history is a lifesaver, bringing the system back to a stable state with just a few simple commands.
How to Rescue Your System in 30 Seconds
If you need to urgently undo an operation you just performed, follow these 3 steps:
- List recent transactions:
sudo dnf historyYou will see a list table. Look at the ID column on the far left to identify the transaction session you want to handle.
- Check what that ID did (e.g., ID 42):
sudo dnf history info 42DNF will list the details of the packages added or removed during that transaction.
- Undo immediately:
sudo dnf history undo 42The system will automatically calculate how to remove what was added or restore what was deleted in step 42.
How dnf history Works
DNF does more than just install files. Every time you run a command that changes the system, DNF creates a Transaction. Everything from the dependency list to the execution time is stored in a SQLite database at /var/lib/dnf/history.sqlite.
Decoding Symbols in the Action Column
When typing sudo dnf history list, pay attention to the abbreviations to understand what happened:
- I (Install): Fresh installation.
- U (Update): Upgraded to a new version.
- E (Erase): Removed from the machine.
- D (Downgrade): Downgraded to an older version.
Small note: If you see a * next to an Action, it means the transaction was interrupted, possibly due to a power outage or accidentally pressing Ctrl+C.
Distinguishing Undo and Rollback: How to Use Them Correctly?
Many people confuse these two commands, but their impact on the system is completely different.
1. dnf history undo
This command focuses on a single transaction. If you installed httpd at ID 20, undo 20 will remove it. It won’t touch anything you installed at ID 21 or 22.
2. dnf history rollback
This is the true “go back in time” command. When using rollback 15, the system will remove/reinstall everything to return the machine exactly to its state at ID 15. All changes from ID 16 onwards will be discarded.
Tip: Rollback may fail if your cache is cleared or if old repositories are no longer available.
History Management Tips for Advanced Users
Don’t let a long history list overwhelm you. Try these ways to filter information:
Track the history of a specific package: Want to know when nginx was updated? Run:
sudo dnf history list nginx
Filter packages you manually installed: Instead of wading through thousands of junk dependencies, the following command only shows what you actively chose to install:
sudo dnf history userinstalled
Practical Experience from the Fedora “Battlefield”
To make using dnf history as smooth as possible, I have a few tips for you:
- Avoid excessive cache cleaning: Don’t overuse
sudo dnf clean all. Cache metadata is crucial for DNF to perform a successfulundo. If you have enough disk space, keep the cache as a backup. - Examine closely before acting: Always run
dnf history infobefore typing an undo command. If the transaction involves thekernelorglibc, be extremely cautious as it could render the system unbootable. - Pay attention to third-party repositories: If you installed an app from RPM Fusion and then disabled that repo, the
undocommand will error out. Ensure the relevant repositories are still active.
Mastering dnf history makes you much more confident when testing new tools on Fedora. You no longer have to fear typing commands, as you always know you have a safe way back. Hopefully, this trick makes your system management effortless.

