I received a report showing a large accumulation of files. How can I delete them?
I believe there may be a large accumulation of temporary files in my Linode. I'd like to delete them to free up space. How can I achieve this?
1 Reply
If you need to locate the directories with the largest accumulation of files, you can run the following command:
sudo du -ahx / | sort -rh | head -n 20
I'll drop a link to a post from our community site which has more suggestions… but since you already have a report, you'd just have to navigate to the directories with the large number of files and delete them.
To do so, you can use the cd
command to access the directory. For example, this directory typically holds temporary files:
cd /var/tmp
Once there, you can use the ls -la
command to view all of the files and their permissions. Here's some example output:
drwxrwxrwt 5 root root 4096 May 18 01:03 .
drwxr-xr-x 14 root root 4096 May 18 00:59 ..
-rw-r--r-- 1 root root 0 May 18 01:03 1test.txt
Then, you can use the rm
command to delete the file:
rm 1test.txt
You can also delete an entire directory using the -R
option. For example:
rm -R /var/[directory]
Here's the community post that I was referring to earlier:
My disk is filling up. How can I find the culprit?
Feel free to share anymore suggestions or resources that you think will be helpful!