0

I want to actually delete files in linux, as opposed to just erasing the representation of a file, with the command rm, for example, actually deleting the file literally, and as a basic good security measure, to prevent any potential data recovery after file deletion.

I want to accomplish this with the basic tools that come with most linux systems ideally. The last time I researched the issue I was led to a tool called something simlar to rmshred which I guess was only in debian repo's.

Maybe some simple compound command would do the trick such as DD random data copied to the file, and then using rm, to faux delete the random data after the fact. And then I guess I can figure out how to alter the rm utility itself to preform this function automatically with some basic customization.

Edit:

I actually want to achieve multiple goals here.

My thinking is to use a compound command utilizing standard utilities that are in most debian/fedora/ect based linux distros.

Get the exact size of the file,

DD or perhaps copy random data or zeroes, of the same size as the file

in place of the exact file/s bits,

and then utilize rm, which just makes the image to the user disappear,

to remove the image of the now randomed, or zeroed former data,

then I want to customize the rm utility itself to perform this basic task,

of actually deleting the file, instead of just superficially doing so.

This is a very basic problem, shouldn't be too hard, I've just never taken the time to figure out how to do it.

  • 1
    Quite fresh cross-site duplicate: [Which Linux shell command can completely remove a file from the system and make it unrecoverable?](https://superuser.com/q/1722508/432690) – Kamil Maciorowski May 28 '22 at 20:49
  • Take a look at shred – enzian May 28 '22 at 20:52
  • really, follow the answer on the question linked above. The assumption that you're overwriting the contents of the file, which only exist in one place on the disk, is plain wrong, and has been wrong for 20 years, since operating systems stopped being on rudimentary file systems like FAT. – Marcus Müller May 28 '22 at 20:52
  • @enzian no. Shred is snake oil, and only helps on non-COW, non-journalling file systems stored on hard drives produced prior to ca 2002 to 2005. You should really read the accepted answer on "How can I be sure...".. – Marcus Müller May 28 '22 at 20:53
  • @MarcusMüller Oh, didn't know that. Thanks for the info. – enzian Jun 01 '22 at 07:58

0 Answers0