1. How to Fix Duplicate Packages in YUM on CentOS 7
i | P a g e
Table of Contents
Overview.......................................................................................................................................................1
Applies To......................................................................................................................................................1
Pre-Requisites ...............................................................................................................................................1
Yum – Error Message....................................................................................................................................1
Error Message – Cause..................................................................................................................................1
Resolution .....................................................................................................................................................2
Install Package – Yum Utils .......................................................................................................................2
Verify Package – Yum Utils........................................................................................................................2
Duplicate Packages – List..........................................................................................................................2
Duplicate Packages – Count......................................................................................................................3
Duplicate Packages – Packages.................................................................................................................3
Duplicate Packages – Clean Duplicates.....................................................................................................3
Remove Packages – Manually...................................................................................................................4
Duplicate Packages – Removal Validation ................................................................................................4
2. How to Fix Duplicate Packages in YUM on CentOS 7
1 | P a g e
Overview
In this guide we will go through the steps of resolving “YUM”, sometimes yum encounters errors, it can
cause RPMDB (database) as inconsistent, duplicate packages are installed, because yum cleanup and
verification process is incomplete, which could be possibly that YUM process is killed or terminated
abruptly.
Applies To
CentOS 7.1.1503 (Core), tested on CentOS 7.x (minimal install)
Pre-Requisites
Internet connection to fetch and install packages.
DHCP or static IP Address enabled or assigned host.
sudo or root access to the host.
Yum – Error Message
When you execute “YUM” to update or install a package, you could get following error message and yum
process gets ended automatically without completing the task that it was intended to perform i.e., when
you try to install or upgrade a package.
Error Message – Cause
One of the main causes of rpmdb inconsistency, when yum is process terminated or killed abruptly;
3. How to Fix Duplicate Packages in YUM on CentOS 7
2 | P a g e
Resolution
In order to resolve this issue, YUM Utils package has to be installed, which can identify duplicate packages
that are installed on the server and subsequently remove those packages with this utility commands.
Install Package – Yum Utils
To resolve the issue, we have to first install “yum-utils” package, to install package run the command;
yum install -y yum-utils -q
Verify Package – Yum Utils
yum list installed yum-utils -q
Duplicate Packages – List
After installation of utility, to list duplicate packages installed on the server, run the command;
package-cleanup --dupes -q | head -5
4. How to Fix Duplicate Packages in YUM on CentOS 7
3 | P a g e
Duplicate Packages – Count
Additionally, you could count duplicate packages installed on the server, though this command is for
information only, run the command;
package-cleanup --dupes -q | wc -l
Duplicate Packages – Packages
As an example, when the command is executed, you can view the duplicate packages, as shown below; in
this example python-urlgrabber has two versions installed on the server.
Duplicate Packages – Clean Duplicates
As shown earlier in order to remove duplicate packages installed on the server package-cleanup
command with “--cleandupes” argument will allow help us in removing duplicate packages installed on
the server, run the command;
package-cleanup --cleandupes
5. How to Fix Duplicate Packages in YUM on CentOS 7
4 | P a g e
Remove Packages – Manually
There are few instances wherein few packages that are not removed with this utility, you could remove
manually with yum erase command, for example;
yum erase <Package Name>
or
yum erase zlib-1.2.7-17.el7.x86_64
Duplicate Packages – Removal Validation
Once you have resolved / removed all the duplicate packages, if you run the command again, below
message will be displayed i.e., “No Problems Found”.
package-cleanup --dupes -q
package-cleanup --problems -q