Ubuntu – How to remove recommended and suggested dependencies of uninstalled packages

aptpackage-management

I know of How to remove an uninstalled package's dependencies? and I tried

apt-get autoremove

but that does not remove dependencies that are recommended/suggested by other packages.

That is, if I install a package X that recommends Y, but I do not install Y, and then I install package Z that depends on Y. and later I do

apt-get remove --auto-remove Z

then Y is not automatically removed even though nothing depends on it.
(X "picked up" Y, even though it does not depend on it).

Best Answer

If you want to remove recommended packages from your system, even if there are still some installed packages recommending (or suggesting) them, put the following in the file /etc/apt/apt.conf.d/99_norecommends (create it):

APT::Install-Recommends "false";
APT::AutoRemove::RecommendsImportant "false";
APT::AutoRemove::SuggestsImportant "false";

The documentation for these options is here.

Then, the next apt run should remove them all. If it doesn't, launch aptitude, and type g and g again.

This configuration also disables the automatic installation of recommended packages when using apt-get. For aptitude it can be done from the console GUI, menu Options > Preferences > "Install recommended packages automatically" (uncheck it).

Related Question