Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am running out of disk space and noted that I have a large /var/cache directory. Can I safely remove this? (using Arch Linux, BTW).

share|improve this question
4  
I'd check through what's in there, but given that's where pacman store's it's packages you might want to run pacman -Sc or even pacman -Scc if you want to clean your entire package cache. –  xenoterracide Oct 23 '11 at 20:02
    
Most, but not all, files under /var/cache are safe to delete. Don't delete the directories or change their ownership. Run du /var/cache/* | sort -n to see what's taking room. Ask here if you don't know whether the large directories are safe to clean. –  Gilles Oct 24 '11 at 1:14
    
What about a disk usage analyzer - alternativeto.net/software/windirstat/?platform=linux –  Aaron Newton Jan 12 '13 at 6:28

4 Answers 4

up vote 9 down vote accepted

No.

For one, I believe that /var/cache/bind/ is the default directory where bind9 expects its zone files to be stored (at least on Debian; I don't know offhand if other distros follow suit)

For another, according to this documentation, pacman (the package manager used by Arch linux) stores its package cache under /var/cache/pacman/pkg/ and it most likely expects nothing but itself to modify the contents.

I recommend you read through the documentation more closely and decide whether this is a good time to clear the package cache.

share|improve this answer
    
Yes, don't delete /var/cache/apt/archives dir, but you can delete files: /var/cache/apt/pkgcache.bin and /var/cache/apt/srcpkgcache.bin, but them will be recreated by "apt-get update". –  diyism Jun 24 '13 at 12:03
    
On Debian, /var/cache/bind contains zone files transferred from other nameservers—it shouldn't contain master zones. Debian follows FHS, and FHS requires that files under /var/cache be deletable. Of course, the question is about Arch, and further one shouldn't delete files without first at least figuring out what they are. –  derobert Nov 12 '13 at 22:32

From http://www.lindevdoc.org/wiki//var/cache

Sorry for the (very) late answer, but I believe it's important to include this bit for future reference.

Highlighted the bit which does answer this question.

The /var/cache directory contains cached files, i.e. files that were generated and can be re-generated any time, but they are worth storing to save time of recomputing them.

Any application can create a file or directory here. It is assumed that files stored here are not critical, so the system can delete the contents of /var/cache either periodically, or when its contents get too large.

Any application should take into account that the file stored here can disappear any time, and be ready to recompute its contents (with some time penalty).

So yes, you may remove these files without expecting anything bad to happen.

share|improve this answer
    
You will have to jump through some hoops if you delete /var/cache and want to use apt afterwards. –  Matthias Braun Mar 6 at 21:56

You can make this determination yourself using lsof.

Run lsof -Pn +D /var/cache/ | awk '{print $1}' | sort | uniq to see which software currently has any open files in that directory. If anything looks moderately important (or you dont know what it is) then do not remove it.

Besides, you shouldn't be just blowing out directories without backups anyways; this even applies to /tmp.

share|improve this answer

Use the apt-get to clean up the local repository:

sudo apt-get clean

share|improve this answer
5  
Arch doesn't use apt –  Michael Mrozek Nov 12 '13 at 21:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.