Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I understand that apt-get remove removes packages and apt-get autoremove is to remove any packages that were installed to fulfil a dependency for a given package. So for example if I installed LibreOffice and it had dependencies on say Java and installed it as part of the installation when I run the command apt-get libreoffice, why would I run the command apt-get remove libreoffice followed by apt-get autoremove? Am I not able to simply run the command apt-get autoremove libreoffice? Or is the combination of apt-get remove and apt-get autoremove for a different purpose?

share|improve this question
add comment

4 Answers

up vote 9 down vote accepted

It depends on how much you trust the dependancy tracker. While almost always correct, there are times when you would want a dependancy to remain, particularly when you are a developer or power user installing software that is not in the repository.

If you always install software through apt-get, without exception, and trust all the dependancies to be correct (which they usually are), then you can use apt-get autoremove and gain a small amount of drive space and a reduced exposure to potential security holes by having it remove packages that no longer have any packages that need them.

But if you install software manually, or develop software, or do not want to deal with a possible dependancy error, then not using autoremove to clear potentially unused packages is probably the safer choice. Regardless of whether you use apt-get autoremove every now and then or not, you will always remove software using apt-get remove Package

For example, if I install AwesomePackage, it may depend on AwesomeLibrary, and thus AwesomeLibrary will get automatically installed as a dependancy. When I remove AwesomePackage using autoremove, as long as no other package has AwesomeLibrary as a dependancy it will be uninstalled as well. But if SuperPackage also requires AwesomeLibrary, or if I had installed AwesomeLibrary explicitly myself rather than having it come in automatically as a dependancy (apt-get install AwesomeLibrary), then autoremove would not get rid of it.

The reason it is not the default is that having AwesomeLibrary on the system, unused, is a very minor issue. It will almost never cause problems, and most dependancies don't take up much space. There are exceptions, but the times when removing a dependancy will cause problems outnumber the times when it will solve or prevent a problem.

share|improve this answer
Sorry Myrddin Emrys. You lost me there. So let me try and understand what you said. So for example if I installed libreoffice using apt-get, it would install a whole bunch of dependencies assuming I didn't have them installed already. Now if I then decide to get rid of libreoffice, I assume I would run apt-get remove libreoffice –  PeanutsMonkey Mar 9 '12 at 6:36
If I wanted the dependencies it installed to remain is that correct? If I wanted to rid myself of both libreoffice and its associated dependencies assuming there were not used by another program, I take it I would run the command apt-get autoremovelibreoffice? Is that correct? –  PeanutsMonkey Mar 9 '12 at 6:36
That is absolutely correct @PeanutsMonkey. Autoremove will also remove other packages that the named package depended on, if they are no longer required by anything and were not installed separately on purpose. –  Myrddin Emrys Mar 9 '12 at 18:54
Actually, that is not absolutely correct; I had some incorrect syntax in my answer (as @cooper pointed out). I have corrected this in the answer above. apt-get autoremove is a separate command from apt-get remove Package, I apologize for the initial misinformation. –  Myrddin Emrys Mar 9 '12 at 19:19
Thanks Myrddin Emrys. Sorry if I am being a n00b. When you say that There are exceptions, but the times when removing a dependancy will cause problems outnumber the times when it will solve or prevent a problem. What do you mean exactly? –  PeanutsMonkey Mar 10 '12 at 7:58
show 1 more comment

You can find the description of remove, autoremove, purge, clean and autoclean, as well as the syntax in the manpages for apt-get: man apt-get.

If you are still unsure after reading it though (I was) the best way to clarify it is to try it out.

Below is an example of a full dependency tree for vim:


You can get it with:

apt-rdepends -d vim > vim.dot
dotty vim.dot

You can also get a list of the immediate dependencies using apt-cache depends (see Declaring relationships between packages for more info):

$ apt-cache depends vim
  Depends: vim-common
  Depends: vim-runtime
  Depends: libacl1
  Depends: libc6
  Depends: libgpm2
  Depends: libselinux1
  Depends: libtinfo5
  Suggests: <ctags>
  Suggests: vim-doc
  Suggests: vim-scripts

So it looks like vim depends on a number of packages, let's attempt to install it with apt-get install and see what happens:

$ sudo apt-get install vim
The following extra packages will be installed:
  vim-common vim-runtime
Suggested packages:
  ctags vim-doc vim-scripts
The following NEW packages will be installed:
  vim vim-common vim-runtime
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
After this operation, 25.1 MB of additional disk space will be used.
Do you want to continue [Y/n]? n

In order to get vim to work we need vim-common and vim-runtime packages and apt-get will take care of it. We can verify it with dpkg -s pkg... (see man dpkg for more info on statuses):

$ sudo dpkg -s libc6
Package: libc6
Status: install ok installed        // we already have it, no need to install

$ sudo dpkg -s vim-common
Package: vim-common
Status: deinstall ok config-files   // we don't have it, have to install

Just as we checked what vim depends on, we can also check what other things depend on the same packages as vim using apt-cache rdepends. We should see vim among (possibly) other things:

$ apt-cache rdepends vim-common
Reverse Depends:
  vim                               // there it is

Let's continue with the installation. Once we have installed vim we can experience the difference between remove and autoremove. Let's attempt to remove first:

$ sudo apt-get remove vim
The following packages will be REMOVED:
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 1,922 kB disk space will be freed.
Do you want to continue [Y/n]? n

apt-get remove would then remove vim but not its dependencies leaving them behind. Let's now try to remove one of the vim's dependencies:

$ sudo apt-get remove vim-runtime
The following packages will be REMOVED:
  vim vim-runtime
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 24.8 MB disk space will be freed.
Do you want to continue [Y/n]? n

This would remove the dependency vim-runtime as well as the package that depends on it, namely vim. Out of curiosity, let's see what would happen if we removed a dependency that is lower on vim's dependency tree:

$ sudo apt-get remove libgpm2
The following packages were automatically installed and are no longer required:
  libgtkglext1 libqtassistantclient4 libtiff-tools libtiff5 python-qt4
  python-sip python-sqlalchemy python-sqlalchemy-ext
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  anki cheese gimp gimp-gmic gimp-plugin-registry gnome-control-center      // !
  gnome-media gnome-video-effects gstreamer0.10-plugins-good libaa1         // !
  libcheese-gtk21 libcheese3 libgpm2 mplayer quodlibet vim vlc w3m          // !
0 upgraded, 0 newly installed, 18 to remove and 0 not upgraded.
After this operation, 63.1 MB disk space will be freed.
Do you want to continue [Y/n]? n

It would remove vim and lots of goodies!

Let's proceed with apt-get remove vim then. Once we have done it we should have some leftovers. If we now try autoremove we can see:

$ sudo apt-get autoremove
The following packages will be REMOVED:
  vim-common vim-runtime
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 23.2 MB disk space will be freed.
Do you want to continue [Y/n]? y

These are the two packages apt-get remove left behind even though nothing else needed them.

Experimented with apt-get

share|improve this answer
add comment

According to this: http://ubuntuforums.org/showthread.php?t=996053 autoremove will remove all packages that other programs do not need. You would do 'apt-get autoremove', not 'apt-get autoremove libreoffice'. Also removing unneeded packages does not just free up a little disk space, it reduces the 'attack surface' of your system.

share|improve this answer
I can see that unused libraries can be an attack vector, but it seems to be a very minor issue to me, relative to the significant pain of improper removal (which I've seen happen more than once). Thank you for the info about usage however... I have actually been describing autoremove improperly (I don't use it myself, so didn't realize), thank you for the correction. –  Myrddin Emrys Mar 9 '12 at 19:10
add comment

remove will delete the specified program whereas autoremove will include dependencies otherwise not used anymore.

Also, If you'd like to free up drive space, a useful and safe command is...

sudo apt-get clean

That removes the aptitude cache in /var/cache/apt/archives

share|improve this answer
Sorry for being such a n00b but I don't quite follow that. So if I run the command apt-get remove libreoffice, I take it that it'll simply remove libreoffice. Is that right? However if I run the command apt-get autoremove libreoffice, that would not only remove libreoffice but also its dependencies? –  PeanutsMonkey Mar 9 '12 at 6:32
That's correct. So let's say that I install neverball and neverball depends on a package called libisfun. If I apt-get remove neverball then it will remove just the neverball package. If I apt-get autoremove neverball then it will remove neverball and libisfun if libisfun is not a dependent on any other application. –  kobaltz Mar 9 '12 at 15:38
add comment

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.