Ubuntu Linux is a popular open-source operating system that is known for its user-friendly interface and ease of use. One of the ways that Ubuntu can free up disk space is by deleting cached package files. To delete cached package files on Ubuntu, follow these steps:
- Open a terminal window and type the following command to start the deletion process: sudo apt-get purge cache
Every time Ubuntu updates or you install some software, the package manager downloads all of the packages to the system, and then caches them there in case they need to be installed again. Unfortunately, this can often mean a real lot of wasted space.
Check the Drive Space Used by Cached Files
To check out the used space for yourself, head into the /var/cache/apt/archives folder, or just run the following command from the prompt:
You’ll see that there’s a lot of space being used—on this testing box, which I’ve barely used, there’s 441 MB sitting there in the cache folder.
Clean Out the Cached Packages
To clean out this folder properly, you can use this command from the shell prompt:
You could, of course, delete the files manually if you wanted to, but that would probably be a mistake since the lock file and the blank partial directory are supposed to stay there—and it’s less keystrokes to type this anyway.
Disable Automatic Package Caching
If you’d rather not have to go in and clean out the cache folders all the time, you can tell Ubuntu to stop keeping them around with a simple configuration change. Head into System –> Administration –> Synaptic Package Manager.
Then choose Settings –> Preferences
Switch over to the Files tab, where you can change the option to “Delete downloaded packages after installation”, which will prevent the caching entirely.
You’ll also notice that you can use the Delete Cached Package Files button from this screen to clean up the packages.