×


YUM History command Ways to use it

Website Administrators sometimes complain about their sites being negatively affected after a recent update. Yum history command comes handy in such situations to review the past update.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Software Installation of their Servers.

In this context, we shall look into the usage of yum history command.


What are the basic syntax for yum history command ?

YUM is an rpm based package manager that enables users to install new packages, remove/erase old/unwanted packages.

YUM history command provided the detailed history of YUM transactions in order to find out information about installed packages and those that where removed/erased from a system.


The basic syntax of the yum history command and its parameters include:

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]


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

1. Info – Provides detailed information about the last update or the update ID you specify.

2. List – Provides a list of the past updates.

3. Packages-list – Takes a package name, and provides a list of all the update IDs where that package was accessed.

4. Packages-info – Takes a package name and provides the historic update information on that package for the current server.

5. Summary – The summary provides an overview of all the transactions that have happened over the last three months.

6. Addon-info – View any additional information about a transaction ID.

7. Redo – This command repeats the work completed in a particular transaction ID.

8. Undo – This command reverses the earlier work done in a specific transaction ID.

9. 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.

10. 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.)

11. Sync – Updates the rpmdb/yumdb data stored for any installed packages to what is current in the repo.

12. Stats – Provides statistics about the current history DB.


Now let us look into some of these subcommands in more details.


1. yum history list command

The "yum history list" or just the “yum history” command shows a detailed information as the one below:

[root@test.net [~]$ yum history


Loaded plugins: fastestmirror, rhnplugin, security, universal-hooks

ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
846 | root <root> | 2020-09-17 05:50 | Update | 134
845 | root <root> | 2020-09-16 05:50 | Update | 218
844 | root <root> | 2020-09-10 05:51 | Update | 79 EE
843 | root <root> | 2020-09-09 05:50 | Update | 5 EE
842 | root <root> | 2020-09-08 05:50 | Update | 2 EE
841 | root <root> | 2020-09-06 05:50 | Update | 1 ##
840 | root &lt;root> | 2020-09-04 05:50 | Update | 1 EE


2. history list

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, 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.


3. Yum history “rollback”

The “yum rollback” 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.


4. 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.


5. 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!


[Need urgent assistance with software updates on your Linux Servers? – We're available 24*7. ]


Conclusion

This article will guide you on #YUM history #command in #Linux which provides a detailed history of YUM #transactions in order to find out information about installed packages and those that where removed/erased from a #system. 

The yum history command allows users to review information about a timeline of Yum transactions, the dates and times they occurred, the number of packages affected, whether transactions succeeded or were aborted, and if the RPM #database was changed between transactions.