Every time you run sudo apt-get install or sudo apt-get upgrade in Ubuntu Linux, the operating system downloads the raw .deb installation packages from the internet. However, after the installation finishes, Ubuntu does not automatically delete those raw downloaded files. It saves them in a hidden local repository known as the APT Cache.
Ubuntu keeps these files indefinitely just in case you ever need to reinstall the exact same version of an app offline. Over months of system updates and software installations, this hidden cache folder (located at /var/cache/apt/archives/) can easily grow to several gigabytes in size, silently filling up your root partition. You can safely wipe this entire directory using a single terminal command without affecting any of your installed applications.
How to Safely Delete the Ubuntu APT Cache
You should never manually delete the files using the rm command, as it can break the package manager’s internal indexing. Instead, use the built-in apt-get clean utility.
- Open your Terminal application (Ctrl + Alt + T).
- First, to see exactly how much space the cache is currently wasting, type this command and press Enter:
du -sh /var/cache/apt/archives - If the number returned is large (e.g., 2.4G), you should clean it. Type the following command and press Enter:
sudo apt-get clean - Type your administrator password when prompted.
The command executes instantly and silently. It safely deletes all downloaded .deb files from the cache while leaving the critical lock files and partial directories intact.
Alternatively, if you want to keep the installation files for the most recent version of your apps but only delete the obsolete, outdated installation files from previous months, you can run the following command instead:
sudo apt-get autoclean
This intelligent command cross-references the cache against the current Canonical servers and only deletes files that are no longer available for download, safely optimizing your drive space while maintaining a useful local backup.