Duplicate packages can sometimes be present in a system due to incomplete or failed yum transactions. This can cause inconsistencies and unexpected behavior in package management. To resolve this issue, it is crucial to identify and safely remove duplicate packages from the system.
Issue Details
Identifying Duplicate Packages
You can check for duplicate packages using the following commands:
- Checking Specific Packages:
rpm -qa | grep -i <package-name>Example:rpm -qa | grep -i git-1.8.Sample Output:perl-Git-1.8.3.1-24.el7_9.noarch perl-Git-1.8.3.1-25.el7_9.noarch git-1.8.3.1-24.el7_9.x86_64 git-1.8.3.1-25.el7_9.x86_64 - Checking for System-Wide Duplicate Packages:
package-cleanup --dupesSample Output:httpd-2.4.6-98.el7_9.7.x86_64 httpd-2.4.6-99.el7_9.1.x86_64 pki-base-java-10.5.18-27.el7_9.noarch pki-base-java-10.5.18-25.el7_9.noarch git-1.8.3.1-24.el7_9.x86_64 git-1.8.3.1-25.el7_9.x86_64
Steps to Remove Duplicate Packages
Step 1: Take a Snapshot of the VM
Before making any changes, take a full snapshot of the virtual machine to ensure you have a restore point in case of any issues.
Step 2: Remove the Duplicate Packages
Once the snapshot is taken, use the following command to remove the older or unwanted duplicate package:
rpm -e <package-name> --nodeps --justdb
Example:
rpm -e httpd-2.4.6-98.el7_9.7.x86_64 --nodeps --justdb
Explanation of Flags:
rpm -e: Removes the package.--nodeps: Ignores dependency checks, which prevents removing dependent packages.--justdb: Modifies the RPM database without actually deleting the package files from the filesystem.
Step 3: Verify the Removal
After removing the duplicates, verify that only the correct package versions remain:
rpm -qa | grep -i <package-name>
Example:
rpm -qa | grep -i git-1.8.
Reference Article
For more details on handling duplicate packages, refer to the following Red Hat Knowledge Base Article:
Title: How to remove duplicate packages from a failed yum transaction
Link: Red Hat Solution
Conclusion
Following the steps above, you can safely identify and remove duplicate packages from your system. Always ensure to take necessary backups or snapshots before proceeding with any package removal to avoid any disruptions.









