apt-get
has a few options which looks the same to me: autoclean
, autoremove
and clean
. What do each of them do?
2 Answers
From the apt-get
man page:
clean: clean clears out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. When APT is used as a dselect(1) method, clean is run automatically. Those who do not use dselect will likely want to run apt-get clean from time to time to free up disk space.
autoclean: Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.
autoremove: is used to remove packages that were automatically installed to satisfy dependencies for some package and that are no longer needed.
Every command has a manual page, if you want to know what their parameters are or what each of them do, just type in the shell `man ` Ex. `man apt-get`

- 3,095

- 7,866
autoclean: removes all stored archives in your cache for packages that can not be downloaded anymore (thus packages that are no longer in the repo or that have a newer version in the repo).
clean: removes all stored archives in your cache.
autoremove: a whole different thing, this option makes apt look for packages that are installed as dependency of an already uninstalled package and removes them. This is used to clean up unused dependencies that remain on your system.
Answer found: http://ubuntuforums.org/showthread.php?t=394952

- 3,095
-
14I choose yours as the good one! because if I want to read the man page, I will get there, but not everytime you want to understand, you are going to find an answer with man, that's why we need a human touch from stackoverflow... And I think this is totally understandable... First answer seems too cold to me – Dazag Sep 20 '18 at 10:49
-
Sorry in advance if my question is too basic or off-topic but just to understand more what exactly did you mean by archives & cache here? – Milan Sep 23 '20 at 19:21
-
3Programs are stored as archives in the repository. That archive is downloaded into a cache on your computer and unpacked from there into the necessary folders. The archive is stored in the cache in case you need to do a repair or reinstall of the program. – Antony Sep 24 '20 at 22:01
-
Another confusion: cache is a part of computer RAM, right? So, upon every reboot, doesn't it get cleared automatically? – Milan Nov 12 '21 at 17:03
-
What apt does is download a file into a special folder (a cache folder) on your hard drive, it then unpacks and installs from that file. The file is then kept for reinstall/repair actions and so is not removed between boots. When installing a new version the old version can be kept in case you wish to return to it. – Antony Nov 13 '21 at 19:26
-
@Antony seems the "of an already uninstalled package and removes them" part should be "of an already installed package and removes them" instead. See the description for
autoremove
in theman apt
– Manuel Jordan Jun 04 '22 at 16:25 -
1@Manuel: The description in the answer is correct. You install A that needs B and C which are then automatically installed. You uninstall A which leaves B and C on the system. autoremove will uninstall B and C since A no longer needs them since it has already been uninstalled. – Antony Aug 07 '22 at 13:56
-
@Antony thanks for the clarification - pls consider to add that info in your current answer. – Manuel Jordan Aug 08 '22 at 19:22
--help
isn't enough I usually usegrep
in both cases, it also has a fun option "--context", whyman apt
doesn't include the cleans? I don't know... - it is within theman apt-get
only, however, try using something likeman apt-get | grep autoclean --context=5
- can be very helpful :-) Otherwise I 100% agree. – jave.web Aug 10 '23 at 08:21