Apt (Advanced Packaging Tool) is a command-line package installation and dependency management utility in Debian-based distributions.
When you install packages in Debian using the apt-get or apt command, a copy of the .deb file is saved in the /var/cache/apt/archives directory. If you uninstall and reinstall a package, your system will look for it in the cache and download it from there rather than downloading it again.
If you run out of disk space on your Debian system, you can clear the apt-cache and free up some space.
In this guide, you will learn how to clear the apt-cache on Debian.
Use apt clean Command
To clear the apt-cache, use the apt clean command to erase all files in the cache directory. The user doesn’t need to manually delete the cache directory.
$ sudo apt clean
You can run the apt clean command with an option called —dry-run. This will simply display the folders from which packages will be deleted.
$ sudo apt clean --dry-run
Use apt auto-clean Command
This command removes all saved archives for packages that can no longer be downloaded from your cache. The packages are either no longer in the repository or have a newer version available in the repo. This command cleans obsolete Debian packages.
$ sudo apt autoclean
Clearing the cache created by apt is completely safe. It is faster and simpler than manually deleting the cache directory.