I am trying to delete a file in linux, (Ubuntu 20.04). As per my understanding, when we delete a file, the inode and directory entry structures are modified first and the file is actually deleted at a later time. This is one of the reasons why the file can be recovered by different tools later.
I want to delete a file and know that it has been physically deleted from the disk. There should be no way that I can retrieve it at any point of time.
shred
is your friend – Panki Jul 07 '20 at 15:13man shred
, it also doesn't promise to work with journaling filesystems, which is… pretty much all of them, these days? I guess you could delete the file and thendd if=/dev/random of=fillthedisk; rm fillthedist
which should fill most space available to files, likely including the old file contents, with randomness. – Ulrich Schwarz Jul 07 '20 at 15:47dd -i /dev/zero
to kill the databefore
you rm it. Not sure why random junk is any harder to recover the data from than zeroes. Special care may be needed for huge sparse files. – Paul_Pedant Jul 07 '20 at 16:57