Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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).

share|improve this answer
I wouldn't recommend not installing recommendations as they most of the time are useful. – Braiam Jan 3 '14 at 0:37
@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

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.

share|improve this answer
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
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
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 – 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>
share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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