How to remove duplicate packages with yum

- by

I’m working on a handful of servers that all have the same problem: when running yum, an error message appears that tells me a package called ntpupdate needs to be upgraded, but somehow this doesn’t work and the package is being skipped. Then follows a huge list of duplicate packages that are installed on those systems (probably installed by the automatic package updater within Plesk).

Let’s see how we can fix such issues.

The Problem

Here’s the output:

yum update

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package ntpdate.x86_64 0:4.2.6p5-22.el7.centos.2 will be updated
--> Processing Dependency: ntpdate = 4.2.6p5-22.el7.centos.2 for package: ntp-4.2.6p5-22.el7.centos.2.x86_64
---> Package ntpdate.x86_64 0:4.2.6p5-25.el7.centos will be an update
--> Finished Dependency Resolution
Error: Package: ntp-4.2.6p5-22.el7.centos.2.x86_64 (@updates)
           Requires: ntpdate = 4.2.6p5-22.el7.centos.2
           Removing: ntpdate-4.2.6p5-22.el7.centos.2.x86_64 (@updates)
               ntpdate = 4.2.6p5-22.el7.centos.2
           Updated By: ntpdate-4.2.6p5-25.el7.centos.x86_64 (base)
               ntpdate = 4.2.6p5-25.el7.centos
 You could try using --skip-broken to work around the problem
** Found 30 pre-existing rpmdb problem(s), 'yum check' output follows:
1:NetworkManager-1.0.6-31.el7_2.x86_64 has missing requires of NetworkManager-libnm(x86-64) = ('1', '1.0.6', '31.el7_2')
1:NetworkManager-1.4.0-13.el7_3.x86_64 is a duplicate with 1:NetworkManager-1.0.6-31.el7_2.x86_64
audit-2.4.1-5.el7.x86_64 has missing requires of audit-libs = ('0', '2.4.1', '5.el7')
audit-2.6.5-3.el7.x86_64 is a duplicate with audit-2.4.1-5.el7.x86_64
binutils-2.25.1-22.base.el7.x86_64 is a duplicate with binutils-

The list goes on. The solution: remove the duplicate packages and start again!

The Solution: Removing duplicate packages

First we need to install something called yum-utils. It’s as easy as this:

yum install yum-utils

Next we’ll display a list of which packages exist more than once on our server. No changes are being made just yet:

package-cleanup --dupes

Loaded plugins: fastestmirror

To remove the oldest versions of all duplicate packages, we’ll issue the package-cleanup –cleandupes command. The output that follows looks almost identical to that of a yum update command, except that things are being erased rather than updated.

When the process has finished, we can use yum update again without trouble.

If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

2 thoughts on “How to remove duplicate packages with yum”

  1. Thanks for the information above. And this solves my problem described below:

    I have the situation that the server is experiencing problems with duplicate packages in the Yum update.
    How to solve this in a way that does not have to cause a stop, or that causes a problem in the server, since it is an internet server, proxy and email …
    Until I found something, but they are very old postings, so I am in doubt if they still apply to the current version of CentOS 7.5.1804 and there is no information if it can cause a problem if I have the risk of removing some package and or configuration in use, and cause the system shutdown, or other serious problem.

    Here’s the situation in .txt file in Google Drive:

    Thanks in advance.

Leave a Comment!

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