ObjectiveThe objective is to remove all orphaned packages from CentOS Linux. By orphaned packages we mean all packages which no longer serve a purpose of package dependencies.
For example, package A is depended on package B, thus, in order to install package A the package B must also be installed. Once the package A is removed the package B might still be installed, hence the package B is now orphaned package.
Operating System and Software Versions
- Operating System: - CentOS 7
RequirementsPrivileged access to you CentOS Linux system will be required.
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of
- $ - requires given linux commands to be executed as a regular non-privileged user
STEP 1First check whether a
package-cleanupis available. If not, use the below command to install it:
# yum install yum-utils
Obtain List of Orphaned PackagesNext, use
package-cleanupto obtain list of orphaned packages currently residing in the system:
$ package-cleanup --leavesThe above command will create a list of all orphaned packages, for review, one package per line.
Remove Orphaned PackagesLastly, use
yum removeto remove the entire list:
# yum remove `package-cleanup --leaves`Note, you might need to run the above commands few times to uninstall all orphaned packages. Make sure to generate a preview of all packages to be removed and review them after each iteration.