Remove orphaned packages in CentOS 7

Remove orphaned packages in CentOS 7

In this tutorial I will show you, how to remove orphaned packages in CentOS 7 server. 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.


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.

Enjoyed this video?
Remove orphaned packages in CentOS 7
"No Thanks. Please Close This Box!"