CentOS / RHEL See Detailed History Of yum history Commands nixCraft Updated Tutorials/Posts

I would like to see detailed information on the history of yum transactions such as updates, deleted packages, and other information. How do I see history of yum commands on a CentOS Linux/ RHEL 6.x or 7.x based server? How do I undo or redo or rollback packages using yum command?The yum command has history option on the latest version of CentOS / RHEL v6.x+. To database are normally found in /var/lib/yum/history/ directory. The history option was added at the the end of 2009 (or thereabouts) to yum command. The history command allows an admin to access detailed information on the history of yum transactions that have been run on a system. You can see what has happened in past transactions (assuming the history_record config. option is set). You can use various command line options to view what happened, undo/redo/rollback to act on that information and start a new history file. This page shows how to use yum history command to find out information about installed, updated, and removed packages.

Prerequisite: Find yum command version on a CentOS/RHEL

You need yum version 3.2.xx or CentOS/RHEL 6.x. Verify this with the following command:# yum info yum | grep --color VersionSample outputs from CentOS v6.5:

Version : 3.2.29

Here is output from the CentOS Linux box:

CentOS / RHEL See Detailed History Of yum commands

The yum history command allows sysadmin to see information about all Yum command transactions including:

s – The transaction finished successfully, but the –skip-broken command line option was used and certain packages were skipped.

To see all transactions, pass the add option as follows:# yum history list allYou can list only one transactions or transactions in a given range:# yum history list 7# yum history list 1..3Sample outputs:

To find out what additional information is available for a certain transaction:# yum history addon-info id# yum history addon-info 24To just get info on last transaction:# yum history addon-info last

How do I undo / revert transactions?

Say, you deleted the nginx package using yum command:# yum erase ngnixNow, use yum history command to review the transaction history, the yum history command provides means to revert or repeat a selected transaction. To revert (undo) a transaction, type the following at a shell prompt as root:# yum history undo idTo undo nginx erase action, type:# yum history# yum history package-list nginxSample outputs:

How do I redo / repeat transactions?

To repeat a particular transaction, run:# yum history redo id

The yum history rollback option

The syntax is:# yum history rollback idThe rollback command will undo all transactions up to the point of the specified transaction. For example, if you have 3 transactions, where package A; B and C where installed respectively. Then “yum history undo 1” will try to remove package A, “yum history redo 1” will try to install package A (if it is not still installed), and “yum history rollback 1” will try to remove packages B and C.

The yum new option

As described above, the yum command stores the transaction history in a single SQLite database file in /var/lib/yum/history/ directory. To start new transaction history, run the following command:# yum history newVerify with the following command:# yum historyI strongly suggest that you read the yum command man page using the man command or this page for more information:$ man yum

Posted by:Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.