If you're anything like me, you probably have Ubuntu running on your older computers, and they often have smaller hard drives so you're looking to save every bit of drive space you can. Here's an easy trick to free up a surprising amount of drive space.

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:

du --sh /var/cache/apt/archives

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:

sudo apt-get clean

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.

image

Then choose Settings --> Preferences

image

Switch over to the Files tab, where you can change the option to "Delete downloaded packages after installation", which will prevent the caching entirely.

image

You'll also notice that you can use the Delete Cached Package Files button from this screen to clean up the packages.