Alt Text
A screenshot of a file manager preview window for my ~/.cache folder, which takes up 164.3 GiB and has 246,049 files and 15,126 folders. The folder was first created about 1.75 years ago with my system
You don’t have to clean your ~/.cache every now and then. You have to figure out which program eats so much space there, ensure that it is not misconfigured and file a bugreport.
Because of excessive RAM I symlink
~/.cache
to/tmp
. Additionally installingzramswap
helps for this scenario.Benefits are faster access, automatc purging between reboots and no wear to the NMVe drive.
Yes, this is a single user scenario.
Once I get more than 16GB of ram I’ll definitely try that
This seems like a filename conflict waiting to happen. Why not just mount a tmpfs there?
Like I said it’s a cheap solution for a single user system. Ofc tmpfs would be better but has to be done for every user again
You: It’s a single user system
Also you: Tmpfs would have to be done for every userAnd a /tmp/ symlink would have to be created for every user too, so I don’t get your point
Tmpfs is just as easy as making a symlink, but without the filename conflicts between files in ~/.config/ and /tmp/. You just need to add a line to /etc/fstab
I don’t think I’ve ever seen .cache get bigger than 10GB
It looks like yay was storing AUR build files there, that folder took up about 160 of the 164GiB
You can use
yay -Sc
to clean the cache. It’ll also ask you if you want to clean the pacman cache, which I’m assuming you also haven’t cleaned (check the size of/var/cache/pacman
).If it is true, it is a bug in yay. Cashe should not grow without limit.
Question, could you have cron/crontab do it monthly or something? Do it monthly meaning delete everything in ~/.cache every month or so?
I just found this today, I don’t really know anything about cron jobs but this will probably incentive me to learn lol
Did you happen to see which subdirectory was using up this much space? I don’t think I’ve ever seen .cache go above 10GB, so this may be a bug in a piece of software you use.
Running
ncdu
on it would’ve been cool to see.Looks like yay is storing every previous binary for AUR bin packages (also excuse the unreadable terminal theme, it doesn’t play very well with a lot of TUI apps unless they support custom theming)
You should run
yay -Sc
from time to time. This cleans a) your pacman cache (which is normally done by executingpacman -Sc
) b) your AUR build cache, which is what’s taking up 160GB. But this one seems rather unusual, I use paru (which also has the commandparu -Sc
), so I can’t really tell if this is normal with yay.The command also asks you for every directory if you want to delete it or not, so it’s completely save to run that command.
Something I noticed was that it was mostly the binary packages that were taking up so much space, it may be because of how yay stores the programs (does it use git?), the ones that were compiled from source code usually took up the least amount of space, while the binary programs were the ones taking up tens of gigabytes
Indeed, yay utilizes the AUR, which essentially serves as a Git repository for each package. These repositories typically include a PKGBUILD file and a .SRCINFO file, along with possible additional files like patches, desktop, or service files.
For example, take a look at IntelliJ Ultimate: [https://aur.archlinux.org/cgit/aur.git/tree/?h=intellij-idea-ultimate-edition]. It contains the .SRCINFO and PKGBUILD, as well as a .desktop file. These files themselves do not occupy much space.
The PKGBUILD specifies the sources for dependencies. For instance:
source=("https://download.jetbrains.com/idea/ideaIU-$pkgver.tar.gz" "jetbrains-idea.desktop")
The PKGBUILD is essentially a Bash script with predefined functions and variables. You can learn more about it here: [https://wiki.archlinux.org/title/PKGBUILD].
This script primarily downloads and extracts the tar file. In this specific case, it only relocates the files to their intended installation locations, like moving the desktop file to /usr/share/applications.
With such packages, there’s a possibility of wasting significant space since the tar file is downloaded and possibly retained in the cache.
However, other packages, especially those compiled from source, usually involve Git clones. These clones bring the Git repository into a subdirectory of the already cloned AUR package Git repo. Some might also have source tarballs. These types of packages generally do not consume much space in the cache, as they are often just text files, like C source code or Python scripts. These packages frequently rely on external libraries and packages, which are not included in this package’s cache.
While binary packages often bundle all necessary libraries and other components in their source tarballs.
The AUR cache is mostly beneficial if you’re rebuilding the same version or can reuse components from a previous version. For example, a package might depend on a large, static file that doesn’t change often.
In Paru, I’ve enabled the “CleanAfter” option to prevent my cache from overflowing. Given my relatively fast internet speed, redownloading large files isn’t a major concern for me.
Wow, I’ve never seen something like this.
Is it" allowed"? I mean, there are quotas for user homes.
Haven’t deleted it yet actually, looks like most of it is from yay
Don’t. You don’t need to clean it unless cache of some buggy program grows uncontrollable.
No way. If i clean up my .cache directory my precious cached with sccache rust deps would be very upset. >:[
…yeah let me go check that…
13,574 totaling 1.7gb, not too bad. Hey OP how do you get to this view? It looks like we both use nautilus but when I select “properties” on the .cache folder it looks different.
I use thunar (with ePapirus-Dark icons which is probably what makes it look like nautilus), I liked nautilus when I used it but thunar has a bit more functionality that I like
Ah thanks!
You can also setup a cron job to periodically clean oldest files for you.
Example: @weekly find ~/.cache -type f -mtime +7 -delete
This will delete everything older than 7 days inside your cache folder.
I just map both the user cache and the /tmp directory to a RAM drive. I allocated 4 GB but in practice it never gets even close to that much, and Linux seems to not be reserving the entire 4 GB at boot so I would assume how much RAM is used depends on how much is actually in your cache.
It also defers cache and tempfile related problems to turning it off and on again.
This particular folder caches many things from various package managers. Won’t hurt to clear, but will fill up again. Maybe consider not using caches when engaging such things.
How?
Depends on the package manager. Check options for whatever you’re running.
Package managers don’t use this directory as well as any other subdirectory of user’s home.
Could have fooled me, because it’s certainly the default for things like brew, flatpak, mpm, and pip. Looks like npm and maven use it on certain Debian based distros as well. I’m betting more of the immutable distros use that directory as well vs something in /var/cache.
Ah, sorry, I thought about system package managers like apt, dnf, zypper etc.
Bleachbit is good for clearing up some space
And deleting emails
$ crontab -e
-
-
- */2 * rm -rf /home/lntl/.cache
-
-
This is one of those things that makes me shake my head about Linux. It’s these small dumb problems that make Linux inaccessible to the common person.
deleted by creator
Not really. I’ve never seen .cache get bigger than 10GB, which is about how big the temporary files in Windows get if you never clean them.
It ended up being yay storing binaries from previous versions of AUR packages, definitely depends on the distro/usage but for arch-based it definitely clears up a lot of storage
I’ve been running Linux as my primary OS since the late 90s and have never run into this problem.
The hate you’re getting for this is so revealing and depressing. It basically proves you right.
To the haters: where is the factual problem with this personal opinion? Have you considered making a counter-argument instead, instead of simply lashing out with the downvote button like spoiled infants? This kind of tribal pile-on really pisses me off. You are literally censoring an opinion expressed in good faith - downvotes hide comments and reduce reputation. All while offering no rebuttal, no ideas of your own, nothing. Nice work.
It is what it is. I’ve been involved in Linux communities long enough to know not to take stuff like this personally.
On Reddit we saw constant posts about why Linux isn’t more popular but no one ever talks about all the dumb little issues that the distros have because of a slight lack of polish. Those little issues make the distros seem cheap compared to the polish of something like Windows.
I’m always amused at the replies I get with things like “When I had Windows it literally caused my CPU to burst in to flames and my SSD shot my dog. Now I’m running Arch and it showed me last night’s winning lotto numbers.”
Ha! Yes I agree completely with all of that.
And with your point here. In this world of pocket touchscreens and voice AIs, where young people don’t even know what a file is any more, the geeks here are reminding each other to empty their .cache directory from time to time. I mean, do they have no self-awareness? Or perhaps they simply don’t care if nobody chooses to use Linux. That at least would be coherent, but if there are no new users then eventually the whole thing will just die.
IMO I’d say the same thing about windows’s “Temp” folder though.
I agree that a lot of Linux isn’t user friendly but I’m also on a distro that is specifically supposed to be customized from the ground up (arch-based) using a tiling window manager which also involves configuring most things from the ground up. This isn’t a problem that most Linux users will likely have, but it is a problem that people may have if they are power users trying to have full control over their system (people who will be on a community about Linux). From what others in this thread have been saying, non-arch distros (and even arch with other aur helpers than yay) tend to have much smaller caches that get up to around 10Gb at most, which is also similar in size to what Windows’s temp directory uses.
This is a Linux community on a FOSS platform. This community is inherently going to be filled with more “geeky” people. Isn’t this what we signed up for? You make it seem like Linux was ever attracting people who weren’t these type of people to begin with. Computer science is still a growing field, and most sane computer science curriculums involve using POSIX terminal commands and by extension linux at some point. I’m a zoomer and can confirm, we’re not all as hopeless as you think we are. Linux will be fine even ignoring all of its corporate and government backing. And for people who don’t even know what a file is, they probably won’t know what Linux is in the first place. Even if they somehow have a system preconfigured with linux, their Ubuntu or Linux Mint install will probably be clearing the cache for them.
Some good points here, I stand partially corrected.
There are in fact 2 completely separate things that irk me. The biggest is the virtual lynching that is mass-downvoting. I’m sorry, I will never ever pardon the downvoting of opinions, I think it’s the illness of the social internet since the very beginning. See my many other recent comments for evidence of how strongly I feel about this.
The other issue is the actual one at hand! You’re right that this cache folder business does not really concern most ordinary users, even on Ubuntu. But actually, if even we geeks need to tell each other to “remember to do X every now and then”, I have enough of an IT mind to think “Why do we need to remember anything?! The tool should do this job for us!” These are “babysitting” chores and IMO on a decent OS there should be zero babysitting, it should be set up once and then it should work forever, with any tweaking optional.
Not a “hater” in terms of trying/wanting to be mean, but I do disagree. I think a lot of people downvoting are frustrated because this attitude takes an issue in one application (yay), for one distro, and says “this is why Linux sucks / can’t be used by normies”. Clearly that’s not true of this specific instance, especially given that yay is basically a developer tool. At best, “this is why yay sucks”. (yay is an AUR helper - a tool to help you compile and install software that’s completely unvetted - see the big red banner. Using the AUR is definitely one of those things that puts you well outside the realm of the “common person” already.)
Maybe the more charitable interpretation is “these kinds of issues are what common users face”, and that’s a better argument (setting aside the fact that this specific instance isn’t really part of that group). I think most people agree that there are stumbling blocks, and they want things to be easier for new users. But doom-y language like this, without concrete steps or ideas, doesn’t feel particularly helpful. And it can be frustrating – thus the downvotes.
Fair enough, tho personally I don’t see this “doom-y language” you see, I just see a slightly exasperated opinion expressed in good grammar and good faith.
But personally I don’t downvote people for their opinions, ever, as a matter of principle. It’s literally a form of censorship, given that it hides the comments. It leads straight to a deadening groupthink where dissenters are scared to open their virtual mouths. It creates a general aura of negativity and intolerance that helps nobody at all. Downvoting, as it is used by most people here and on the R-site, is an absolute scourge. If anything makes me leave this community, it will be this.