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?
Linux – When would you use apt-get remove over apt-get autoremove
apt-getlinuxpackage-managementUbuntu
Best Answer
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.