How To Use The YUM History Command

Reading Time: 6 minutes

Have you ever wanted to review past updates or roll back an update that broke your sites or negatively affected some aspect of your server’s operations? Well, you can accomplish this easily by using the yum history command.

Let’s begin with the basic syntax of the yum history command and its parameters:

root@host:~# yum history
root@host:~# yum history <command> #ID
root@host:~# yum history [options]
root@host:~# history [info|list|packages-list|summary|addon-info|redo|undo|rollback|new]

In this article we will be mainly focusing on these four subcommands of the history command: 

  • list 
  • redo 
  • undo 
  • rollback

Parameter Detail

yum icon2

The yum history command contains several subcommands that are available to use. Here is a brief list of what these subcommands can do.

  • Info – Provides detailed information about the last update or the update ID you specify.
  • List – Provides a list of the past updates.
  • Packages-list – Takes a package name, and provides a list of all the update IDs where that package was accessed.
  • Packages-info – Takes a package name and provides the historic update information on that package for the current server.
  • Summary – The summary provides an overview of all the transactions that have happened over the last three months.
  • Addon-info – View any additional information about a transaction ID.
  • Redo – This command repeats the work completed in a particular transaction ID.
  • Undo – This command reverses the earlier work done in a specific transaction ID.
  • Rollback – This command rolls back the RPM’S to their previous configuration. This option can operate on multiple transactions to roll back instead of a single ID.
  • New – Wipes out the current yum history to provide a fresh, blank history file. (Only use this if you have a problem with yumdb/rpmdb.)
  • Sync – Updates the rpmdb/yumdb data stored for any installed packages to what is current in the repo.
  • Stats – Provides statistics about the current history DB.

Yum history “list”

Let’s begin by reviewing the list subcommand. When you use the command “yum history list” or just the “yum history” command, you can see detailed information like the output listed below:

[root@test.net [~]$ yum history
Loaded plugins: fastestmirror, priorities, universal-hooks
ID 	| Command line 	| Date and time	| Action(s) | Altered
----------------------------------------------------------------------
15 | --assumeyes --config /et 	| 2020-01-22 14:09 	| I, U 	| 84
14 | update -y 	| 2020-01-21 11:18 	| Update 	| 1
13 | update -y 	| 2020-01-19 11:18 	| Update 	| 2
12 | install jwhois | 2020-01-17 15:51 	| Install 	| 2
11 | update -y 	| 2020-01-13 11:18 	| Update 	| 6 <
10 | update -y 	| 2020-01-07 11:18 	| Update 	| 1 >  
9| --assumeyes --config /et | 2020-01-02 14:09 	| Update | 1
8 | update -y 	| 2019-12-25 11:18 	| Update 	| 1
7 | update -y 	| 2019-12-19 11:18 	| Update 	| 76
6 | update -y 	| 2019-12-18 11:18 	| Update 	| 1 E<
5 | update -y 	| 2019-12-13 11:18 	| Update 	| 8 >
4 | install vim | 2019-12-10 20:02 	| Install 	| 1 ##
3 | remove vim 	| 2019-12-10 20:02 	| Erase 	| 1 EE

This command provides us with a summary of all the distinct installs/uninstalls that have been implemented on the server since the yum history was initialized. In the output from the “history list” command above, you will notice the “Altered” column which provides additional information in the form of “>”, “<”, “*”, “#”, “E”, “P”, and “S” symbols.

Here is a detailed summary of what those symbols mean as identified in the yum manpage and what they signify.

> - The rpmdb was changed, outside yum, after the transaction.
< - The rpmdb was changed, outside yum, before the transaction.
* - The transaction aborted before completion.
# - The transaction completed, but with a non-zero status.
E - The transaction completed fine, but had warning/error output during the transaction.
P - The transaction completed fine, but problems already existed in the rpmdb.
s - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.

From the information listed in this table, you can see the separate transactions as well as the details about them. The vital information to note here is the ID numbers provided on the list. Those numbers and how they can be utilized are further detailed in the next command.

Yum history “rollback”

Next, we are going to review the “yum rollback” command option. This command has more versatility than the “undo” option has available. The rollback option essentially allows us to completely revert all of the updates that have taken place, back to a specific ID number. Below is a useful example of this option. We have installed vim and vim-go in two separate transactions.

[root@test.net [~]$ yum history
Loaded plugins: fastestmirror, priorities, universal-hooks
ID | Command line       | Date and time   | Action(s)   | Altered
----------------------------------------------------------------------
17 | install vim-go 	| 2020-01-23 04:18 	| Install 	| 5
16 | install vim 	| 2020-01-23 04:16 	| Install 	| 1
15 | --assumeyes --config /et 	| 2020-01-22 14:09  | I, U 	| 84

Now, if we run the command “yum history rollback 15” you will note that it reverts the earlier changes the yum install made to how they appeared previously on transaction 15.

[root@test.net [~]$ yum history rollback 15
Loaded plugins: fastestmirror, priorities, universal-hooks
Rollback to transaction 15, from Wed Jan 22 14:09:53 2020
 Undoing the following transactions: 16, 17
 Dep-Install golang-1.13.3-1.el7.x86_64 	@epel
 Dep-Install golang-bin-1.13.3-1.el7.x86_64 	@epel
 Dep-Install golang-src-1.13.3-1.el7.noarch 	@epel
 Dep-Install mercurial-2.6.2-10.el7.x86_64 	@system-base
 Install 	vim-enhanced-2:7.4.629-6.el7.x86_64 @system-base
 Install 	vim-go-1.8-3.el7.x86_64 	@epel
Resolving Dependencies
--> Running transaction check
---> Package golang.x86_64 0:1.13.3-1.el7 will be erased
---> Package golang-bin.x86_64 0:1.13.3-1.el7 will be erased
---> Package golang-src.noarch 0:1.13.3-1.el7 will be erased
---> Package mercurial.x86_64 0:2.6.2-10.el7 will be erased
---> Package vim-enhanced.x86_64 2:7.4.629-6.el7 will be erased
---> Package vim-go.x86_64 0:1.8-3.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================
 Package		Arch		Version		Repository		Size
=====================================================================
Removing:
 Golang	      x86_64	1.13.3-1.el7	@epel	7.8 M
 Golang-bin   x86_64	1.13.3-1.el7	@epel	249 M
 Golang-src   noarch	1.13.3-1.el7	@epel	48 M
 Mercurial    x86_64	2.6.2-10.el7	@system-base	12 M
 Vim-enhanced x86_64	2:7.4.629-6.el7	@system-base	2.2 M
 Vim-go	      x86_64	1.8-3.el7	@epel	234 k

Transaction Summary
=====================================================================
Remove 6 Packages

Installed size: 319 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Erasing : vim-go-1.8-3.el7.x86_64		1/6
 Erasing : golang-bin-1.13.3-1.el7.x86_64	2/6
 Erasing : golang-1.13.3-1.el7.x86_64	3/6
 Erasing : golang-src-1.13.3-1.el7.noarch	4/6
 Erasing : mercurial-2.6.2-10.el7.x86_64	5/6
 Erasing : 2:vim-enhanced-7.4.629-6.el7.x86_64 6/6
 Verifying : 2:vim-enhanced-7.4.629-6.el7.x86_64 1/6
 Verifying : golang-src-1.13.3-1.el7.noarch 2/6
 Verifying : vim-go-1.8-3.el7.x86_64 3/6
 Verifying : golang-1.13.3-1.el7.x86_64 4/6
 Verifying : golang-bin-1.13.3-1.el7.x86_64 5/6
 Verifying : mercurial-2.6.2-10.el7.x86_64 6/6

Removed:
golang.x86_64 0:1.13.3-1.el7 golang-bin.x86_64 0:1.13.3-1.el7 golang-src.noarch 0:1.13.3-1.el7 mercurial.x86_64 0:2.6.2-10.el7 vim-enhanced.x86_64 2:7.4.629-6.el7 vim-go.x86_64 0:1.8-3.el7

Complete!

As you can see, the above command removed both of the vim and vim-go installs, as well as all of the related dependencies. 

Yum history “redo”

Now, using our last example where we uninstalled vim and vim go, we can use the “yum redo” command to reinstall vim from the transaction ID #16 as noted in the history table above. 

[root@test.net [~]$ yum history redo 16
Loaded plugins: fastestmirror, priorities, universal-hooks
Repeating transaction 16, from Thu Jan 23 04:16:11 2020
 Install vim-enhanced-2:7.4.629-6.el7.x86_64 @system-base
Loading mirror speeds from cached hostfile
 * EA4: 208.100.0.204
 * cpanel-addons-production-feed: 208.100.0.204
 * cpanel-plugins: 208.100.0.204
 * epel: mirrors.liquidweb.com
201 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.629-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================
 Package	Arch	Version		Repository		Size
=====================================================================
Installing: Vim-enhanced 
               x86_64	2:7.4.629-6.el7	system-base		1.1 M
Transaction Summary
=====================================================================
Install 1 Package

Total download size: 1.1 M
Installed size: 2.2 M
Is this ok [y/d/N]: y
Downloading packages:
Vim-enhanced-7.4.629-6.el7.x86_64.rpm		1.1 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : 2:vim-enhanced-7.4.629-6.el7.x86_64		1/1
 Verifying : 2:vim-enhanced-7.4.629-6.el7.x86_64		1/1

Installed:
 vim-enhanced.x86_64 2:7.4.629-6.el7

Complete!

As you can see, the yum command loaded up the transaction and reinstalled vim. This command can be handy as it will try to install the exact version used as it existed previously at that time. If you are trying to roll back an install to a specific version number or reinstall an older version of the software, the “redo” option is the preferred course of action.

Yum history “undo”

Much like the rollback command noted above, we are going to expand on the last transaction and demonstrate how the “history undo” command functions. To undo an operation, we need to run the “yum history undo” command with the specific “ID” number of the transaction that you want to revert back to. 

[root@test.net [~]$ yum history undo 16
Loaded plugins: fastestmirror, priorities, universal-hooks
Undoing transaction 16, from Thu Jan 23 04:16:11 2020
 Install vim-enhanced-2:7.4.629-6.el7.x86_64 @system-base
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.x86_64 2:7.4.629-6.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================
 Package 	Arch 	Version 	Repository 	Size
=====================================================================
Removing:
 vim-enhanced 	x86_64 	2:7.4.629-6.el7 @system-base 	2.2 M

Transaction Summary
=====================================================================
Remove 1 Package

Installed size: 2.2 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Erasing	: 2:vim-enhanced-7.4.629-6.el7.x86_64 	1/1
 Verifying : 2:vim-enhanced-7.4.629-6.el7.x86_64 	1/1

Removed:
 vim-enhanced.x86_64 2:7.4.629-6.el7

Complete!

And that’s it! This is an excellent example of how to run the “undo” option using the “yum history” command.

Conclusion

We have listed the history of our installs, rolled back an update, reinstalled the previous version of vim, and lastly, undid an updated installation. In closing, we will display the history list again so you can see what changes have taken place today and what they looked like.

[root@test.net [/]$ yum history list
Loaded plugins: fastestmirror, priorities, universal-hooks
ID 	| Command line 		| Date and time	| Action(s) 	| Altered
----------------------------------------------------------------------
20 | history undo 16 	 | 2020-01-23 04:56 | Erase   | 1 
19 | history redo 16 	 | 2020-01-23 04:42 | Install | 1 
18 | history rollback 15 | 2020-01-23 04:27 | Erase   | 6 EE
17 | install vim-go 	 | 2020-01-23 04:18 | Install | 5 
16 | install vim         | 2020-01-23 04:16 | Install | 1 
15 | --assumeyes --config /et 	| 2020-01-22 14:09 | I, U | 84 
14 | update -y           | 2020-01-21 11:18 | Update  | 1  

We hope this information about the yum history command makes it easier to track down and correct any update/installation issues you may run into.

We’re Waiting For Your Call!

Our dedicated support team can provide information about this topic and many more if you run into any problems with your server or system.

If you are experiencing any type of issue that has you at a stopping point, simply give us a call at 800.580.4985, or open a chat or a ticket with us to speak with one of our knowledgeable support technicians to learn how you can take advantage of techniques like these today!

Author Bio

About the Author: Mike Shooltz

Having worked in the IT field for just over a decade now, Mike enjoys writing bash/perl scripts and the challenge of working with new software, as you never know what you're getting into. When he is not at work, he enjoys working on his various side projects, making maps for D&D games and playing video games.

Refer a friend and get a $50 hosting credit!