Nov 252015
 

One of the most frequently used commands by Linux administrators of a Red Hat or CentOS system is the yum package management tool.

Yum History – What For?

Some would argue that Yum is the most powerful tool in a Linux systems administrator’s command line arsenal.

So what does yum do?

Yum is used for installing and upgrading packages, checking for updates, searching for packages, listing installed and available packages, downloading packages, adding and enabling/disabling repositories and installing local packages.

The beauty of yum is that when you install an update or package it automatically resolves dependencies (i.e. it installs all the other software required for your package to work).

But why is the yum history of any importance to a Linux administrator?

Knowing what commands we ran with yum and when we ran them is extremely useful in investigating problems, should they arise, and to roll back updates or remove packages if necessary.

Here are a few key commands to check yum history.

Remember to run yum history commands as root or sudo.

1. List the Last 20 Yum Transactions

$ sudo yum history list
Loaded plugins: aliases, changelog, fastestmirror, langpacks
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
   102 | update mate*             | 2015-11-24 09:32 | Update         |    1   
   101 | update atril             | 2015-11-24 09:31 | Update         |    3  
   100 | update -y                | 2015-11-18 10:15 | Update         |    1 
    99 | update -y                | 2015-11-14 09:09 | Update         |    1   
    98 |                          | 2015-11-11 14:14 | Erase          |    4 EE
    97 | update -y                | 2015-11-11 09:29 | Update         |    1 EE
    96 | update -y                | 2015-11-06 15:11 | Update         |    6
    [output truncated]

2. List All Yum Transactions

The below command will spit out the entire history of yum commands which can go back a year or even earlier depending on the age of your CentOS or RedHat system.

$ sudo yum history list all
Loaded plugins: aliases, changelog, fastestmirror, langpacks
ID     | Login user  | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
   103 | michaelpc   | 2015-11-25 16:14 | Update         |    1   
   102 | michaelpc   | 2015-11-24 09:32 | Update         |    1   
   101 | michaelpc   | 2015-11-24 09:31 | Update         |    3  <
   100 | michaelpc   | 2015-11-18 10:15 | Update         |    1 > 
    99 | michaelpc   | 2015-11-14 09:09 | Update         |    1   
    98 | michaelpc   | 2015-11-11 14:14 | Erase          |    4 EE
    97 | michaelpc   | 2015-11-11 09:29 | Update         |    1 EE
    [output truncated]

3. Selective Yum History

The yum history command is flexible enough that you can tweak it to get the output you want.

For instance, in the below example we’re looking at yum history from IDs 20 through 25.

$ sudo yum history list 20..25
Loaded plugins: aliases, changelog, fastestmirror, langpacks
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    25 | install clamtk-5.15-1.el | 2015-03-30 08:06 | Install        |   44   
    24 | install clamav clamtk    | 2015-03-30 08:00 | Install        |    4   
    23 | groupinstall MATE Deskto | 2015-03-23 09:38 | Install        |  133   
    22 | install docker           | 2015-03-22 08:51 | Install        |    1   
    21 | install yum-plugin-chang | 2015-03-13 21:57 | Install        |    2   
    20 | install yum-plugin-alias | 2015-03-13 21:55 | Install        |    1

4. Specific Yum Event
In this below example from my CentOS 7 system, when I ran yum history for ID 25, I found that on March 30, 2015 at 8:06AM I’d installed the Clam anti-virus software.

Now you see how powerful yum history is.

$ sudo yum history list 25
Loaded plugins: aliases, changelog, fastestmirror, langpacks
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    25 | install clamtk-5.15-1.el | 2015-03-30 08:06 | Install        |   44

5. Yum History Summary

When all you’re looking for is the summary of yum history, the below command is what you’d run.

$ sudo yum history summary
Loaded plugins: aliases, changelog, fastestmirror, langpacks
Login user    | Time                | Action(s)        | Altered 
-------------------------------------------------------------------------------
michaelpc     | Last day            | Update           |        1
michaelpc     | Last week           | Update           |        4
michaelpc     | Last 2 weeks        | Update           |        2
michaelpc     | Last 3 months       | D, E, I, U       |      208
michaelpc     | Last 6 months       | E, I, O, U       |      313
System        | Last 6 months       | Install          |        1
michaelpc     | Last year           | E, I, O, U       |     2026
System        | Last year           | I, U             |    363

Folks, I hope the above post has given you a good overview of yum history commands.

 Posted by at 9:58 pm  Tagged with:

Sorry, the comment form is closed at this time.