• ARTICLES
SEARCH

How-To Geek

How to Free Up a Lot of Disk Space on Ubuntu Linux by Deleting Cached Package Files

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.

image

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.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 09/13/10

Comments (5)

  1. trm96

    Mine was 800MB, can’t believe it…

  2. Col

    I recommend using aptoncd to create a backup of the packages before doing a cleanup.

  3. Larry Thiel

    Looks like yet another reason to NOT remove Synaptic from Meerkat. The users ubuntu is targeting with all the ease of use (a.k.a. dumbing down) features would rather use a GUI for this simple task.

  4. john

    I couldn’t get it to work unless I used: du -s -h ………….. Am I missing something?

  5. oliwek

    “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”…

    I suppose this concerns apps installed with synaptic, but not through aptitude or apt-get… so you still have to “sudo aptitude clean” after a “sudo aptitude install name_of_package_here”, right?

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!