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).

  • 1
    Could you instead say what is the package that do this? – Braiam Sep 28 '13 at 20:22
  • There are many examples, so I tried to extract the essence of the problem in the above description. You are right that I should have also included a concrete example: Consider installation of texlive-full. It installs a lot of font packages, which are suggested (but not required) by many pre-existsing packages (I cannot remember precisely which, but I think pre-existing libreoffice or matplotlib or octave suggested these). So the problem is that "apt-get install texlive-full" followed by "apt-get remove --purge --auto-remove texlive-full" does not leave the system in the same original state. – user2809402 Oct 9 '13 at 18:48

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).

  • I wouldn't recommend not installing recommendations as they most of the time are useful. – Braiam Jan 3 '14 at 0:37
  • 1
    @Braiam This is not what the OP asked though. Your comment is for him, not for me. – Totor Jan 3 '14 at 0:40
  • I'm just saying that that's maybe overkill. – Braiam Jan 3 '14 at 0:40
  • @Braiam That's your POV. I live pretty well with InstallRecommends disabled. For the record, it was disabled by default until Debian Squeeze released, that is since February 2011 (don't know about Ubuntu). Furthermore, you may not need the same configuration on a server or a desktop setup. – Totor Jan 3 '14 at 0:43
  • 1
    InstallRecommends: Because why install 5MB of stuff you want, when you could also install 1GB of stuff you don't want? – Mark K Cowan Jan 31 '17 at 18:56

apt-get autoremove will leave "recommended" and "suggested" packages behind. The logic is a bit puzzling, it goes like "maybe some other package is using them" (without registering anything about it in APT).

But, following the same logic, APT could as well flatly refuse to uninstall anything because, you never know.

Anyway, you can remove all "recommended" and "suggested" packages on your system in a single command, without having to modify the configuration:

sudo apt-get autoremove -o APT::Autoremove::RecommendsImportant=0 -o APT::Autoremove::SuggestsImportant=0

However be warned. I did this on my system, it freed up a lot of space, however I had to manually reinstall some packages to regain lost functionality, such as being able to mount FAT partitions, for example. (exfat-fuse was an optional/suggested dependency of fuse, if I remember well). I ended up reinstalling all the recommended/suggested packages to save myself the trouble.

I don't know of any easy way to specify that you would want the optional/suggested dependencies of particular packages uninstalled. apt-get does not offer such option.

Other package managers might be better at this. Some package managers (DNF) have a "transactional" approach to package management, which means you can roll-back to a previous point.

Actually the command is:

sudo apt-get autoremove <Z>

But this has a trick! If any of the dependencies has some other previously installed packages that recommend/suggest them then apt would not remove them.

You didn't specified what package was but for example, if I were to install the IcedTea plugin, it would install Java/OpenJRE by dependencies. If I uninstall them using sudo apt-get autoremove icedtea-7-plugin you would notice that it won't remove Java/OpenJRE, since LibreOffice also suggests the packages.

So, to remove them you has to be overly specific about the package you wants to uninstall that normal autoremove won't:

sudo apt-get autoremove <Z> <dependency of Z>

This way you could be sure your package get removed.

You can also use deborphan to remove some dependencies.

  • By the way, my understanding from the apt manpage is that autoremove does not expect a package name, and will simply clean all un-needed package dependencies in the system. So you would have to do 2 steps: "apt-get remove Z" followed by "apt-get autoremove". These 2 steps can be done at once with "apt-get remove --auto-remove Z", as mentioned in my original question. But like I said, the problem is that there are some leftover packages which are not removed if they were suggested by something else. – user2809402 Oct 9 '13 at 18:26
  • 1
    Yes, you described my problem perfectly. Thank you. But, unfortunately, you have not solved it, because I do not want to go to /var/log/apt/history.log and look for all the packages Y that where installed a couple of months ago with Z (in your example, Y=java/jre, Z=icedtea plugin) and then manually add all of them to the apt command line. I want to only specify Z, and the rest of the dependencies to be picked up automatically, even if they are suggested by another existing package X (X=libreoffice in your example). – user2809402 Oct 9 '13 at 18:29
  • 1
    Unfortunately,this is the way the apt system works, it prefers to keep packages installed rather than remove them, even if they are not needed anymore. The only way to remove them is manually or with deborphan but deborphan may miss some packages still. You can use the Debug:: options and also check my other answer about this. You can also use the --no-install-recommends, but apt-get don't install suggested packages by default. – Braiam Oct 9 '13 at 18:46
  • @user2809402 you should also check askubuntu.com/q/244470/169736 – Braiam Oct 9 '13 at 18:52
  • Braiam- Thanks for the deborphan pointer. I will check it out. – user2809402 Oct 9 '13 at 20:10

Right, if you want to remove package <Z> with dependances just type:

sudo apt-get autoremove --purge <Z>
  • 3
    Thanks, but unfortunately, adding "--purge" simply removes the configurations of packages that are removed with "autoremove". But as far as I can see, it does not change the decision about which packages to remove. That is, dependencies of Z which are suggested by some pre-existing package X, are still not removed, whether or not I specify "--purge". – user2809402 Oct 9 '13 at 18:37
  • 1
    Also, autoremove works system-wide. So anytime you call autoremove, it will remove all unused packages on your system. Installing a package, then autoremoving will usually not return the system to the same state, and will instead leave a bunch of "leftover" packages. – Rolf Jan 29 at 19:51

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.