I have an operating system update routine where I’ve stashed a few commands to install updates, but also clean up unused packages to free up some hard drive space.
sudo apt-get update && \
sudo apt-get upgrade -y && \
sudo apt-get install -fy && \
sudo apt-get autoremove -y && \
sudo apt-get autoclean -y && \
sudo sync && sudo sync
I’ve never taken the time to review if both apt-get autoclean and apt-get autoremove are both necessary in this routine. So let’s take a look at the apt-get man page:
autoclean (and the auto-clean alias since 1.1)
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 (and the auto-remove alias since 1.1)
autoremove is used to remove packages that were automatically installed to satisfy dependencies for other packages and
are now no longer needed.
So apt-get autoclean will clean out packages that are no longer downloadable from your deb repositor(y/ies), while apt-get autoremove will uninstall packages that are no longer needed.