Submind YouTube summaries
Thumbnail for Cleaning Up Cache Files on Linux

Cleaning Up Cache Files on Linux

Watch on YouTube

Video summary

The video begins by addressing the common issue of limited hard drive space on Linux systems and introduces practical methods to identify where storage is being consumed. The presenter first uses the `df` command with the `-H` flag to display partition usage in human-readable gigabytes rather than raw bytes, providing a clear overview of available versus used space. He then suggests an alternative tool called `ydu`, which offers a visual representation of disk usage, though he notes its availability depends on specific repositories and distributions. Once the current storage status is established, the focus shifts to the home directory's cache folder, where applications store temporary data that can often be safely removed without affecting system stability. Inside the cache directory, the presenter demonstrates how to analyze file sizes using the `du` command combined with sorting techniques to prioritize cleanup efforts. He highlights a specific challenge in organizing these results: standard numerical sorting fails when dealing with mixed units like kilobytes and gigabytes unless the `-h` flag is used alongside the sort options. By piping the output of `du -h` into `sort -rh`, he successfully arranges folders by size, revealing that his web browser cache alone consumes nearly eight gigs. This step-by-step analysis allows users to identify large directories associated with specific applications, such as thumbnail generators or unused desktop environment components like Tracker 3 from GNOME, which can be deleted if those services are no longer in use. The tutorial concludes with a strategy for safely removing old files without deleting critical data needed by active programs. The presenter uses the `find` command to locate and delete files older than 365 days within specific cache directories, effectively reclaiming several gigabytes of space on his laptop. He emphasizes that while clearing an entire cache folder is generally safe—though it may cause websites to load slightly slower or require thumbnail regeneration—it is wise to selectively remove data from applications no longer used, such as old test files for mind games. Ultimately, the video encourages users to regularly audit their system caches, starting with the largest folders first, to maintain a healthy disk environment and ensure they always have sufficient free space available for daily operations.
Read the full video transcript
Hello and welcome to a video from filmsbycchrist.com. That's Chris with the K. I'm Chris with the K. Today we're going to be clearing out some old files. You may not need anymore. Clear up space on your hard drive. Let's see how much space we have on our hard drive. We're going to start off with the DF command. If we just type DF, it's going to list our all our partitions and drives and how much being used, but showing us here in bytes. I don't want to see bytes. I want to see human readable. So, we're going to run the same command with -H for human readable. And here now it's showing us in gigs a little bit easier. You can see my main partition here, my root partition. I've used almost 80% of it. You can see how much space is free, how much I've used, and how much uh total I have. Another great tool, if you have it installed, it may be in your repository depending on your DRO uh disk. But with a Y, it will give you a nice little visual here like this, and I can quickly see how much space is on my root directory. Now that we know how much space we have, let's go ahead and see what we can clear out. I'm in my home directory. I'm going to move into a directory called cache. Uh and remember, a dot file, that means it's a hidden file. by default you can't see this but it's there even if you don't see it in your visual or if you list out things and you're not listing hidden files you wouldn't see it but cd into cache in your home directory and here we can list out files this is where applications will store cache stuff that it's going to use but isn't necessarily you could delete everything in here and you'll probably be okay but certain things may need to regenerate like if you're using a file browser uh that generates thumbnails you may have to regenerate thumbnails uh one of the biggest ones in here usually is for me is my web browser and clearing that out. Not going to, but it might log you out of sites. Uh, sites might take a little longer to load the next time you go to them because they aren't cached anymore. So, you may not want to delete everything here. Let's have a look at what's in here, how much is being used. I'm going to use the du command. Uh, du will list everything out. But again, it's not showing it in human readable format. That's, you know, we want to say du-h. Now, we get gigabytes and megabytes and kilobytes. You can see I have 28 gigs worth of stuff in here. Uh, but let's go ahead and clean that up a little bit more. We're going to run that same command. We're going to say d-max- depth and I'm going to say equals 1. This is going to calculate everything up the same, but not display anything more than one folder deep. So, it's just going to show me my current folders and how big they are. So, there you go. I can break this down, but they're not in numeric order. It would be really helpful if it was in numeric order. Of course, I can pipe this into sort, but that's not going to really work like I want it to, right? uh because it doesn't know, you know, it's just going alpha numerically. And now if we look at man and we say sort, we look at the man page for this. In the past, I've talked about the dash n option, which is to sort numerically, but we don't want to just sort numerically. That'd be fine if we were just going bytes, but since we're using kilobytes and megabytes and gigabytes, we want to again use the -h option for human numeric sorting. So now we run our du command and we pipe it into sort. We give it the -h option. Now, it's going to run through that and list all out. We got our total at the bottom here because, of course, that's going to be the biggest number because it's everything added up. But I can see right here, Brave browser is using up almost eight gigs. I probably could clear some of that out, but I'm just going to leave it for now on this drive. But you can see I have this thumbnails folder. The thumbnails folder again is probably uh thumbnails that were generated for my file browser. Uh I also have this one here, this track three. That seems a little suspicious. Again, you could delete everything in this cache folder and you'll probably be okay. Again, you might get logged out of websites. Things might load a little bit slower next time you go to them, but it's not going to probably hurt anything. But I can go in like uh this Froid CL. That's uh Froid um for uh your phone. This application allows me to search the database stuff and install stuff on my phone for it. I don't really use that anymore. I use my own scripts and one and a half gigs is kind of huge for that. It's probably caching apps that I installed. I can just remove that, right? No, no harm, no foul there. Uh, and then this tracker 3, that sounds a little suspicious. I had to look that up. Uh, that's part of the Gnome Desktop uh, functionality. It's like their search tool and it's caching stuff. I don't use the Gnome Desktop. I haven't in years. It's quite possible that I loaded something up that that uses the Gnome Desktop. Or maybe I started up Gnome Desktop once. I haven't done a fresh install in years. Anytime I get a new computer, I just clone my hard drive over to it. So, there's probably stuff lingering here. But since I'm not using them, I feel pretty comfortable just deleting that directory. Um, but something like the thumbnails here. What do we do with that? If it generate thumbnail, if I delete that, yeah, so might have to regenerate thumbnails, but I may not want it to. But let me go ahead and just go in here. And I think it'd be safe for me to say if I haven't generated the thumbnail in the last year, maybe it can be removed. So, while I'm in here, I can say this. This is going to say find dash type for file because we're going to ignore directories. Not that it really matters in this. Uh, and we're going to say time plus 365 days. So, it's going to list anything that is older or created more than 365 days ago. That's great. But again, let's let's uh let's do du-h I forget the number. What was it like two and a half gigs? Oh, there's almost almost four gigs worth of stuff in here. Uh, so what I'm going to do is I'm going to run that find command and I'm going to say dash delete. Again, be careful using this in many cases, but this is going to delete all those files that are more than 365 days old. Do that. And then we will run our U command. And look, now we're less than a gig. So, I've cleared out some space, you know, and my current hard drive on my desktop here is a terabyte, but my laptops only have 256 uh gigabytes. So, I'm always uh kind of close. I try to always keep at least 20 gigs free, but uh you know, sometimes it gets close and I got to go through usually there's some video files I don't need on there anymore, but this also helps. I could clear out yesterday I think I cleared out like 20 gigs or something on my laptop doing this. So, just go through that cache file. Anything that looks like it's not important that you don't use anymore, maybe see the name of a program you don't use anymore, you could probably remove it. Again, if you delete everything in here, you'd probably be okay. Uh, but of course it's always helpful to start with the biggest folders first. So like this and you go, okay, well Brave, I'm gonna delete that. Pup tier I do use that, but I don't want to delete that. Mozzilla, I do use Firefox as a test web browser or sometimes some websites don't like the fact that I'm using Brave, even if I turn off the shields. I'll have to pop into Mozilla. Uh, Firefox, Thunderbird's uh, pretty big here, but I'm going to leave that for now. Google, I don't even know. I You know what? I don't know what that is. It's gone now. I don't know if that's something from years and years ago. I've tried to de Google my life as much as possible. Like mine tests. I don't play mind test. I've loaded it up before to play with my kids. I can remove that. So, you can clear out a lot of stuff. Anything in here you see that you don't use regularly, you can clear out and free up space in your hard drive. I hope you found this useful. I hope you uh learned something new. with some of these commands. Uh, you know, uh, before I started doing this, I don't think I realized the, uh, sort-H option for sort. I, like I said, I've done numeric before. Um, I'm sure I've probably used that before and just didn't remember it. Uh, but if you learned something new, let me know in the comments below. I thank you for watching. Visit filmsby.com. That's Chris the K. Have a great day.