How to Use ‘Yum History’ to Find Out Installed or Removed Packages Info

[‘

n

YUM is an interactive, rpm based, high level package manager for RHEL/CentOS systems, it enables users to install new packages, remove/erase old/unwanted packages. It can automatically run system updates and does dependency analysis, and also perform queries on the installed packages and/or available packages plus so much more.

n

In this article, we will explain how to view history of YUM transactions in order to find out information about installed packages and those that where removed/erased from a system.

n

Suggested Read: 20 Linux YUM Commands for Package Management

n

Below are some examples of how to use the YUM history command.

n

View Complete YUM History

n

To view a full history of YUM transactions, we can run the command below which will show us the: transaction id, login user who executed the particular action, date and time when the operation happened, the actual action and additional information about any thing wrong with the operation:

n

# yum history rn

n

View Yum History
View Yum History

n

Use Yum to Find Package Info

n

The history sub-commands: info/list/summary can take a transaction ID or package name as an argument. Additionally, the list sub-command can take a special argument, all meaning – all transactions.

n

The previous history command is equivalent to running:

n

# yum history list allrn

n

And, you can view details of transactions concerning a given package such as httpd web server with the info command as follows:

n

# yum history info httpdrn

n

Yum - Find Package Info
Yum – Find Package Info

n

To get a summary of the transactions concerning httpd package, we can issue the following command:

n

# yum history summary httpdrn

n

Yum - Find Summary of Package
Yum – Find Summary of Package

n

It is also possible to use a transaction ID, the command below will display details of the transaction ID 15.

n

# yum history info 15rn

n

Yum - Find Package Info Using ID
Yum – Find Package Info Using ID

n

Use Yum History to Find Package Transaction Info

n

There are sub-commands that print out transaction details of a specific package or group of packages. We can use package-list or package_info to view more info about httpd package like so:

n

# yum history package-list httpdrnORrn# yum history package-info httpdrn

n

Yum - Find Package Transaction Info
Yum – Find Package Transaction Info

n

To get history about multiple packages, we can run:

n

# yum history package-list httpd epel-releasernORrn# yum history packages-list httpd epel-releasern

n

Yum - Find Multiple Packages Info
Yum – Find Multiple Packages Info

n

Use Yum to Rollback Packages

n

Furthermore, there are certain history sub-commands that enable us to: undo/redo/rollback transactions.

n

    n

  1. Undo – will undo a specified transaction.
  2. n

  3. redo – repeat the work of a specified transaction
  4. n

  5. rollback – will undo all transactions up to the point of the specified transaction.
  6. n

n

They take either a single transaction id or the keyword last and an offset from the last transaction.

n

For example, assuming we’ve done 60 transactions, “last” refers to transaction 60, and “last-4” points to transaction 56.

n

Suggested Read: How to Use ‘yum-utils’ to Maintain Yum and Boost its Performance

n

This is how the sub-commands above work: If we have 5 transactions: V, W, X, Y and Z, where packages where installed respectively.

n

# yum history undo 2    #will remove package Wrn# yum history redo 2    #will  reinstall package Wrn# yum history rollback 2    #will remove packages from X, Y, and Z. rn

n

In the following example, transaction 2 was a update operation, as seen below, the redo command that follows will repeat transaction 2 upgrading all the packages updated by that time:

n

# yum history | grep -w "2"rn

n

Yum - Find Package Transaction ID
Yum – Find Package Transaction ID

n

# yum history redo 2rn

n

Yum Redo Package Update
Yum Redo Package Update

n

The redo sub-command can also take some optional arguments before we specify a transaction:

n

    n

  1. force-reinstall – reinstalls any packages that were installed in that transaction (via yum install, upgrade or downgrade).
  2. n

  3. force-remove – removes any packages that were updated or downgraded.
  4. n

n

# yum history redo force-reinstall 16rn

n

Yum - Force Install Package
Yum – Force Install Package

n

Find Yum History Database and Sources Info

n

These sub-commands provide us information about the history DB and additional info sources:

n

    n

  1. addon-info – will provide sources of additional information.
  2. n

  3. stats – displays statistics about the current history DB.
  4. n

  5. sync – enables us to alter the the rpmdb/yumdb data stored for any installed packages.
  6. n

n

Consider the commands below to understand how these sub-commands practically work:

n

# yum history addon-inforn# yum history statsrn# yum history syncrn

n

To set a new history file, use the new sub-command:

n

# yum history newrn

n

We can find a complete information about YUM history command and several other commands in the yum man page:

n

# man yumrn

n

Suggested Read: 4 Ways to Disable/Lock Certain Package Updates Using Yum

n

That’s it for now. In this guide, we explained various YUM history commands to view details of YUM transactions. Remember to offer us your thoughts concerning this guide via the comment section below.

n

‘]