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?
I understand that
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
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
For example, if I install
The reason it is not the default is that having
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.
Also, If you'd like to free up drive space, a useful and safe command is...
That removes the aptitude cache in /var/cache/apt/archives
You can find the description of remove, autoremove, purge, clean and autoclean, as well as the syntax in the manpages for 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:
You can also get a list of the immediate dependencies using
So it looks like vim depends on a number of packages, let's attempt to install it with
In order to get vim to work we need vim-common and vim-runtime packages and
Just as we checked what vim depends on, we can also check what other things depend on the same packages as vim using
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:
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:
It would remove vim and lots of goodies!
Let's proceed with
These are the two packages
Experimented with apt-get 0.9.7.9.