A tip to easily delete very HUGE Files(50-300GB) in Linux ?

In this article, we will see how to delete very large files in Linux quickly and easily.

We all know that we can delete rsing “rm -rf” command.

[root@nglinux ~]# du -sh file2
9.8G	file2
[root@nglinux ~]# rm -rf file2
[root@nglinux ~]# 

Now suppose it is of 50Gb and you will delete it, then it will take high resources to delete the file.

So we can redirect some characters and then delete the file.

[root@nglinux ~]# du -sh file2
9.8G	file2
[root@nglinux ~]# echo "hello" > file2
[root@nglinux ~]# du -sh file2
4.0K	file2
[root@nglinux ~]# rm -rf file2
[root@nglinux ~]# 

Here we have echoed some arbitrary contents to the file file2 and all its contents are overwritten.

And the size is reduced to 4K from 9.8GB, and now it will be deleted quickly.

I hope you liked the small tip.

Please do post your comments/suggestions.

0 0 votes
Article Rating
Notify of

1 Comment
Oldest Most Voted
Inline Feedbacks
View all comments
2 years ago

list all files larger than 5G (run it as a root)
find / -type f -size +5G 2>/dev/null or
find / -type f -size +5G -exec ls -lh {} \;

Remove all files larger than 5GB:
find / -type f -size +5G -exec rm -f {} \;

instead of ‘/’ you can type specific path, eg, /home/user1
2>/dev/null = redirects errors