121

I am in the process of cleaning up my system. And I see a lot of space occupied by this folder /var/cache/apt/archives (1.5GB). Is it absolutely necessary to keep all these archives?

137

You don't need to keep them around if you don't want them. Executing a

sudo apt-get clean

will clean out the directory.

  • Why after I have issued this command I still can see the cached deb files in the Ubuntu Tweek tool? – Cristiano Jul 22 '16 at 16:59
  • @Cristiano it might be that the tool is in a partially-installed state and so apt thinks it needs to keep it. – Doktor J Aug 6 at 16:14
41

Seems like

sudo apt-get autoclean

is a better choice than

sudo apt-get clean

autoclean will only remove "useless" archives

From the man page:

Like clean, autoclean clears out the local repository of retrieved package files. The difference is that it only removes package files that can no longer be downloaded, and are largely useless. This allows a cache to be maintained over a long period without it growing out of control. The configuration option APT::Clean-Installed will prevent installed packages from being erased if it is set to off.

  • 9
    Even if this is what I also remembered from way back - turns out, for me (on 11.04) autoclean did NOT remove files in /var/cache/apt/archives/ - while clean did... – sdaau Mar 4 '14 at 20:18
  • I'm actually seeing the opposite, autoclean basically emptied the directory while clean did nothing. – alanaktion Dec 24 '14 at 18:32
  • just brilliant... The first things i found so easy .. :p – mtk Sep 16 '16 at 21:41
  • No, clean is the better choice if you want to save disk space. My testing (ubuntu 18) showed clean removed 18G when autoclean removed little (less than 1 GB, if that) – gerardw Jul 14 at 16:15
6

You can adjust settings in Synaptic package manager, menu Settings/Preferences, the Files tab. From there you can also delete the cache.

1

It is better to save packages elsewhere then clean it up [Jorge Castro's process]. When you reinstall OS or a package it will not download again which save time and bandwidth. apt-get first check require packages in local storage[/var/cache/apt/archives] if does not exists then download else just do install. So you can save packages for future uses.

  • 4
    I doubt he will need all the 1,5Gb of updates to use on a new system! – Bruno Pereira Oct 12 '11 at 20:13
  • 1
    They can be moved on a CD or other support, so they don't waste space on the local drive. This is called a 'local repository'. – ignis Nov 7 '12 at 20:37
  • 1
    Save packages elsewhere? Yes, that's what I've done here. I've mv'd the whole /var/cache/apt/archives to /usr/tmp/apt-archive-cache and set an archives symbolic link in /var/cache/apt accordingly. Since especially audacity likes to store temporary files in /var, this directory should always be taken care of so that it never runs out of space. – syntaxerror Oct 2 '14 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.