remove packages including unused dependencies on Red Hat Linux


Very often you 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.

After compiling your source code you might want to get rid of the development tools:

If you compare the number of dependent packages you recognize that 31 packages will unnecessarily stay on your system!

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!

Leave a comment

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