View yum history to find packages info
In this article
Yes, you can use the yum history command to view a detailed log of past package transactions, and you can inspect individual entries to find exactly which packages were installed, updated, or removed. This is one of the most reliable ways to audit changes on a RHEL, CentOS, Fedora, or Rocky Linux system.
What yum history actually records
Yum (and its successor DNF) maintains a transaction history in the RPM database. Every time you install, remove, update, or downgrade a package, yum records the transaction with a unique ID, the date and time, the user who ran it, and the full list of packages affected. This data is stored in the history database, typically under /var/lib/yum/history/ on older systems or /var/lib/dnf/history/ on newer ones.
The history is not just a simple text file. It is a structured database (SQLite) that yum reads and formats for you. You can query it directly with SQL, but the built-in yum history command is designed to give you human-readable output without needing to know the schema.
Basic commands to view history
The most common commands you will use are:
yum history– shows a summary list of all transactions, with ID, date, action, and number of packages.yum history list– same as above, but with more detail per transaction.yum history info ID– shows full details for a specific transaction ID.yum history summary– gives a quick count of installs, updates, removals, and other actions.
For example, running yum history might produce output like:
ID | Command line | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 7 | install httpd | 2025-03-15 14:22 | Install | 3 6 | update kernel | 2025-03-10 09:05 | Update | 2 5 | remove old-app | 2025-03-02 16:40 | Erase | 1 4 | install nginx | 2025-02-28 11:11 | Install | 5
Each ID is a sequential number. The “Altered” column shows how many packages were affected in that transaction.
Getting detailed package info from a specific transaction
To see exactly which packages were involved in a given transaction, use yum history info ID. For instance, yum history info 7 would show:
Transaction ID : 7
Begin time : 2025-03-15 14:22:00
End time : 2025-03-15 14:23:30
User : root
Return-Code : Success
Command Line : install httpd
Packages Altered:
Install httpd-2.4.57-1.el9.x86_64
Install httpd-tools-2.4.57-1.el9.x86_64
Install apr-1.7.0-11.el9.x86_64
Install apr-util-1.6.1-6.el9.x86_64This output gives you the exact package name, version, release, and architecture. It also shows the command that was run, the user, and the return code. If a transaction failed, the return code will be non-zero, and you can investigate why.
Undoing or redoing a transaction
One of the most powerful features of yum history is the ability to undo or redo a transaction. If you installed a package that caused problems, you can revert to the state before that transaction with:
yum history undo ID
This will remove the packages that were installed and reinstall any that were removed. Similarly, yum history redo ID will reapply a transaction that was previously undone. These commands work by comparing the package lists before and after the transaction and then performing the necessary operations.
Be careful: if you have made other changes since that transaction, undo may not be straightforward. Yum will warn you if there are conflicts, and you can use --skip-broken or --allowerasing only if you understand the consequences.
Common problems and pitfalls
Here are a few issues you might run into when using yum history:
- History is empty – If you have never used yum or dnf, or if the history database was deleted,
yum historywill show nothing. You can still check/var/log/yum.logor/var/log/dnf.logfor older logs, but they are not as structured. - Transaction ID not found – If you try to undo an old transaction that has already been undone or superseded, yum may say it cannot find it. This happens when the package state has changed significantly.
- Large history – Over time, the history database can grow. You can prune it with
yum history newto start a fresh history, but that deletes old records. - DNF vs YUM – On Fedora and RHEL 8+, the default command is
dnf, butyumis often aliased to it. The history commands are identical, sodnf historyworks the same way.
Alternatives to yum history
If you need to find out whether a specific package is currently installed, or what version, you do not need history at all. Use:
rpm -qa | grep package-name– lists installed packages matching a pattern.rpm -q package-name– shows the exact version of a single installed package.yum list installed– lists all installed packages in a yum-friendly format.yum provides /path/to/file– finds which package provides a given file.
History is specifically for answering “what changed and when,” not for checking current state. For auditing, you can also export history to a file with yum history list > history.txt for later review.
Frequently Asked Questions
Can I see the history of a single package?
Yes, you can use yum history list package-name to show only transactions that affected that package. For example, yum history list httpd will list all transactions where httpd was installed, updated, or removed. To see full details of each, use yum history info ID after finding the relevant ID.
Does yum history work on Fedora with DNF?
Yes. On Fedora and RHEL 8+, yum is a symlink to dnf, and the history commands are fully supported. You can also type dnf history directly. The output format is nearly identical.
How far back does yum history go?
It goes back as far as the history database has been maintained. By default, yum keeps all transactions unless you manually clear them. However, if you use yum history new, it will start a new database, and old entries are lost. On some systems, the log rotation may also affect the underlying database, but in practice history persists for years.
Can I undo a transaction that removed a package?
Yes. If you removed a package and want to restore it, find the transaction ID with yum history, then run yum history undo ID. Yum will reinstall the removed package(s). If the package is no longer available in the repositories, the undo will fail, and you may need to find the RPM elsewhere.
Is there a way to see who ran a transaction?
Yes, the yum history info ID output includes the “User” field, which shows the username that executed the command. This is useful on multi-user systems to track who made changes.