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).

  • 6
    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 'SO- stop being evil' 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


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.

  • 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
  • 6
    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
  • 27
    That's like saying you shouldn't delete files in the temporary directory in windows without knowing what they are. If the folder is intended for temp files and your program puts non-temporary data there, then that's a huge problem for your program, not for /var/cache – Tor Valamo Feb 18 '15 at 1:27

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.

  • 9
    You will have to jump through some hoops if you delete /var/cache and want to use apt afterwards. – Matthias Braun Mar 6 '14 at 21:56
  • @MatthiasBraun - For those of us not in the know, is lindevdoc.org a canonical source of truth for this sort of thing? – eykanal Feb 3 '20 at 18:52
  • I don't know lindevdoc.org (I'm not the author of the answer). The site seems to be offline. – Matthias Braun Feb 4 '20 at 1:11
  • The Wayack Machine has that page archived (but only once): web.archive.org/web/20130511220135/http://www.lindevdoc.org/… ... The original poster here literally did more work than the author of that page, as you'll see, since they at least bolded and formatted the text ;-) – Brent Rittenhouse Oct 4 '20 at 4:36

As others have said, /var/cache/ can be used by any application to store information to save on retrieval time. In my experience though, most of the space taken up in there is from the system's package manager.

From the Arch Linux wiki:

pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically, therefore it is necessary to deliberately clean up that folder periodically to prevent such folder to grow indefinitely in size.

pacman -Sc

However, unless storage space is a desperate issue, to save headache later from future incompatibility; one of these other tools should be utilized: paccache, pkgcacheclean, or pacleaner.

For other system:

Redhat based (Fedora, CentOS, SL, ...)

yum clean all
# or
dnf clean all

Debian based (Ubuntu, ...)

apt-get autoclean

SUSE based

zypper clean
  • 2
    +1! I noticed today that I am running out of disk space...a short du -hs /* 2> /dev/null revealed that /var was very big. Turned out that my pacman cache was 91GB. pacman -Sc cleaned up the old packages and reduced the pacman cache to 5GB! – daniel451 Aug 14 '17 at 2:42
  • 1
    This article is a more verbose version of the instructions in the arch wiki on how to use paccahce – joelostblom Mar 29 '18 at 12:50

Found this post interesting in that I was looking to delete from /var/cache on Ubuntu 15.10 for disk space improvement, this is what I have found:

/var/cache/apt cache files are removed after 'sudo apt-get clean' has been run, however the directory structure remains which is no problem if you are looking for disk space improvements; 'apt-get clean' should be run last if you are to get any disk space improvement with apt-get [auto]remove/[auto]clean etc.

As for everything else in the directory, I couldn't agree more with 'Tor Valamo' and his explanation. It's cache, the system and apps that use cache should be able to regenerate anything they have created there. You just have minor performance overheads as cache is regenerated from app to app

In saying that, every system may not conform to this principal, do some testing, try moving everything in your cache directory to a new location and test that your system and all your applications work before removing the cache permanently.


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. If a file is currently in use, your removal will not register until after the handler is closed (you'll see it gone in the file system). More over, removal can cause other programs that are currently running (see the lsof command above) to crash if an expected file that's there is missing.

Basically, only remove files that you know are safe to remove and are not currently being used by other running software.

Your Answer

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