man apt-get
says:
autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
So why is it not automatically called every time I remove package?
EDIT
Essentially, my question is: Why use remove <pkg name>
and not autoremove <pkg name>
to remove packages.
PS: This won't break dependency as said here
See the AptGet/Howto - Ubuntu Documentation page to clear your doubts.
It says:
This command removes packages that were installed by other packages and are no longer needed.
This command removes an installed package and dependencies.
and
This command removes an installed package, leaving configuration files intact.
EDIT
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 usingapt-get remove Package
For example, if I install
AwesomePackage
, it may depend onAwesomeLibrary
, and thusAwesomeLibrary
will get automatically installed as a dependancy. When I removeAwesomePackage
using autoremove, as long as no other package hasAwesomeLibrary
as a dependancy it will be uninstalled as well. But ifSuperPackage
also requiresAwesomeLibrary
, or if I had installedAwesomeLibrary
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.Source: SuperUser: When would you use apt-get remove over apt-get autoremove?
Because,
remove
only remove the package that you want to remove, not it's dependencies. Let see:I installed
xorg
which depends (among other things) ofxserver-xorg
.xserver-xorg
is marked as Automatic, and while I keep installedxorg
it will not be uninstalled byautoremove
. Now, I callapt-get remove xorg
, which tells apt-get to do whatever it takes to removexorg
, and since it only needs to remove that package it doesn't take further action. Why? Because you only told him to remove that package and nothing else. You didn't tell him what to do with the dependencies, nor with other packages.apt-get
is a good boy and follow your order with dot and comma, without trying to be smart doing things you didn't ask him to do, and I like it that way.With
apt-get autoremove xorg
you tell apt-get to do whatever it takes to removexorg
and any Automatic dependency that was installed byxorg
. Thenapt-get
follows your order and removexorg
andxserver-xorg
and any other dependency ofxorg
that is marked as Automatic and don't have any other dependency to fulfill.Lets take another scenario, I installed
xorg
andxserver-xorg
and none is marked as Automatic. If I callremove
onxorg
only xorg will be deleted. If I callautoremove
onxorg
only xorg will be deleted. If I callremove
onxserver-xorg
, both xserver-xorg and xorg will get deleted, because you are telling apt-get to do whatever it takes to remove xserver-xorg but since xorg also depends of xserver-xorg, apt-get don't want to leave broken dependencies while following your orders, hence delete it.But here is the fun, if you call
autoremove
onxserver-xorg
it will uninstall any dependency marked as Automatic of xserver-xorg and xorg itself. Weird, huh? This is because apt-get takes this set of orders from you. In a nutshell, this are the actions, in the exact order, you tell apt-get whenever you call:apt-get autoremove xserver-xorg
apt-get remove xserver-xorg
apt-get remove xorg
apt-get autoremove xorg
As you can see, every set of order has in the end "Don't do anything else" once he fulfilled every command. That is why you only remove only the target with remove.