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.

Leave a Reply

Your email address will not be published.