Remove all orphaned packages from CentOS Linux. By orphaned packages we mean all packages which no longer serve a purpose of package dependencies.
– requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
– requires given linux commands to be executed as a regular non-privileged user
First check whether a package-cleanup is available. If not, use the below command to install it:
# yum install yum-utils
Obtain List of Orphaned Packages
Next, use package-cleanup to obtain list of orphaned packages currently residing in the system:
$ package-cleanup --leaves
The above command will create a list of all orphaned packages, for review, one package per line.
Remove Orphaned Packages
Lastly, use yum remove to 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.