Remove packages including unused dependencies on Linux

Very often we install a package just for short usage.
Most of the time do these packages install a lot of dependencies along with it. After you don’t require the package anymore you remove it but the dependencies are not removed. Every unused package increases the security risk and it also needs some space.

A good example is an environment for compiling from sources.

$> yum groupinstall “Development tools”
...
Transaction Summary
==============================================
Install  19 Packages (+21 Dependent packages)
...
After compiling your source code you might want to get rid of the development tools:

$> yum groupremove “Development tools”


Transaction Summary
==============================================
Remove 25 Packages (+2 Dependent packages)

And here is the solution:

There is a nice plugin called “yum-plugin-remove-with-leaves” which does what it says to do.

Now you can suffix a yum remove command with “–remove-leaves”, which will remove any unused dependencies along with the package.
If you want this behaviour by default you can modify “/etc/yum/pluginconf.d/remove-with-leaves.conf” and set “remove_always” to true:

Taking our example from above you see the difference:

All the 58 packages that were installed are going to be removed!

(Visited 1 times, 1 visits today)

Leave A Comment

Your email address will not be published. Required fields are marked *