This functionality already exists in GNU coreutils, it's done by the shred(1) command. No need to install any extra third-party software, shred is already installed. Also, as another commenter already pointed out, this kind of in-place overwrite is not guaranteed to work on SSDs, and it's also not guaranteed to work on filesystems with copy-on-write semantics. If you're really concerned with this, you should be doing…
Looking at man shred, apparently one can shred stdout.
Rm does not permanently delete files
51–55 of 55 posts
Re: Rm does not permanently delete files
#52Author himself stated that rm has a -P flag, that actually does the same thing more correctly and more securely: >Files are overwritten three times, first with the byte pattern 0xff, then 0x00, and then 0xff again, before they are deleted. Plus the -P flag is available on both GNU and BSD versions of rm. Somehow I fail to see the user-friendliness factor. Edit: formatting
[pritam@PritePad ~]$ cat /etc/lsb-release
LSB_VERSION=1.4
DISTRIB_ID=Arch
DISTRIB_RELEASE=rolling
DISTRIB_DESCRIPTION="Arch Linux"
[pritam@PritePad ~]$ touch t
[pritam@PritePad ~]$ rm -P t
rm: invalid option -- 'P'
Try 'rm --help' for more information.
`man rm` does suggest looking at shred(1) in the SEE ALSO sectionRe: Rm does not permanently delete files
#53When using the terminal command rm (or DEL on Windows), files are not actually removed. Yes they are. As a user, I see a file, type rm file, then it is gone. The file has been removed. Yes those parts of that file are possibly recoverable back into the original file, even without much work, but the file has been removed.
The file, yes, but not the file contents. Worst of all, if you opened the file recently with any process, there is a pretty good chance that the file-descriptor can be found in: /proc/ somewhere. And with that in mind you can use a combination of lsof , grep , sed or any other tool to still read the file as it was.
Neither this tool nor GNU shred nor BSD `rm -P` can do anything about it.
Re: Rm does not permanently delete files
#54This functionality already exists in GNU coreutils, it's done by the shred(1) command. No need to install any extra third-party software, shred is already installed. Also, as another commenter already pointed out, this kind of in-place overwrite is not guaranteed to work on SSDs, and it's also not guaranteed to work on filesystems with copy-on-write semantics. If you're really concerned with this, you should be doing…
Looking at man shred, apparently one can shred stdout.
dtal@reepicheep:~$ cat /dev/urandom | shred -
shred: -: invalid file typeRe: Rm does not permanently delete files
#55Earlier quoted context omitted.
Looking at man shred, apparently one can shred stdout.
And yet it doesn't "work": dtal@reepicheep:~$ cat /dev/urandom | shred - shred: -: invalid file type
You need to point stdout to an actual file, like this:
shred > /my/secret/file.txt
Why would you do this? At the end of a long batch of commands that all write to some temporary file opened on stdout. Not uncommon in shell-land.