yum history

On RHEL/CentOS, yum history is not well-known but is a nice way to undo package installs, including dependencies, or updates. Usage is self-explanatory. I provided some examples below:

joe@unix ~ % sudo yum history
Loaded plugins: fastestmirror
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    36 | install openvpn          | 2020-04-25 17:07 | Install        |    2
    35 | install mc               | 2020-04-25 17:07 | Install        |    1
    34 | history undo 33          | 2020-04-25 17:07 | Erase          |    5

joe@unix ~ % sudo yum history list 36
Loaded plugins: fastestmirror
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    36 | install openvpn          | 2020-04-25 17:07 | Install        |    2
history list

joe@unix ~ % sudo yum history list 35
Loaded plugins: fastestmirror
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    35 | install mc               | 2020-04-25 17:07 | Install        |    1
history list

joe@unix ~ % sudo yum history undo 35
Loaded plugins: fastestmirror
Undoing transaction 35, from Sat Apr 25 17:07:13 2020
    Install mc-1:4.8.7-11.el7.x86_64 @base
Resolving Dependencies
--> Running transaction check
---> Package mc.x86_64 1:4.8.7-11.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================================================
 Package                               Arch                                      Version                                              Repository                                Size
=====================================================================================================================================================================================
Removing:
 mc                                    x86_64                                    1:4.8.7-11.el7                                       @base                                    5.6 M

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

Installed size: 5.6 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:mc-4.8.7-11.el7.x86_64                                                                                                                                        1/1
  Verifying  : 1:mc-4.8.7-11.el7.x86_64                                                                                                                                          1/1

Removed:
  mc.x86_64 1:4.8.7-11.el7

Complete!

joe@unix ~ % sudo yum history undo 36
Loaded plugins: fastestmirror
Undoing transaction 36, from Sat Apr 25 17:07:47 2020
    Install     openvpn-2.4.8-1.el7.x86_64      @epel
    Dep-Install pkcs11-helper-1.11-3.el7.x86_64 @epel
Resolving Dependencies
--> Running transaction check
---> Package openvpn.x86_64 0:2.4.8-1.el7 will be erased
---> Package pkcs11-helper.x86_64 0:1.11-3.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================================================
 Package                                        Arch                                    Version                                         Repository                              Size
=====================================================================================================================================================================================
Removing:
 openvpn                                        x86_64                                  2.4.8-1.el7                                     @epel                                  1.2 M
 pkcs11-helper                                  x86_64                                  1.11-3.el7                                      @epel                                  137 k

Transaction Summary
=====================================================================================================================================================================================
Remove  2 Packages

Installed size: 1.3 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : openvpn-2.4.8-1.el7.x86_64                                                                                                                                        1/2
  Erasing    : pkcs11-helper-1.11-3.el7.x86_64                                                                                                                                   2/2
  Verifying  : openvpn-2.4.8-1.el7.x86_64                                                                                                                                        1/2
  Verifying  : pkcs11-helper-1.11-3.el7.x86_64                                                                                                                                   2/2

Removed:
  openvpn.x86_64 0:2.4.8-1.el7                                                           pkcs11-helper.x86_64 0:1.11-3.el7

Complete!

If you really want you can undo (redo) a previous undo:

joe@unix ~ % sudo yum history undo 38
Loaded plugins: fastestmirror
Undoing transaction 38, from Sat Apr 25 17:09:52 2020
    Erase openvpn-2.4.8-1.el7.x86_64      @epel
    Erase pkcs11-helper-1.11-3.el7.x86_64 @epel
Loading mirror speeds from cached hostfile
 * base: mirror.webruimtehosting.nl
 * epel: ftp.nluug.nl
 * extras: mirror.widexs.nl
 * remi-php72: remi.mirrors.cu.be
 * remi-safe: remi.mirrors.cu.be
 * updates: mirror.cj2.nl
digitalocean-agent                                                                                                                                            | 3.3 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package openvpn.x86_64 0:2.4.8-1.el7 will be installed
---> Package pkcs11-helper.x86_64 0:1.11-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================================================
 Package                                         Arch                                     Version                                       Repository                              Size
=====================================================================================================================================================================================
Installing:
 openvpn                                         x86_64                                   2.4.8-1.el7                                   epel                                   523 k
 pkcs11-helper                                   x86_64                                   1.11-3.el7                                    epel                                    56 k

Transaction Summary
=====================================================================================================================================================================================
Install  2 Packages

Total download size: 579 k
Installed size: 1.3 M
Is this ok [y/d/N]:

yum history info number can be used to show more details, like installed packages about a package transaction. Omitting the number will show the most recent transaction.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.