Ask Your Question

how to securely and permanently delete a file? [closed]

asked 2011-09-29 00:33:39 -0500

shanks gravatar image

updated 2011-09-29 01:28:11 -0500

mether gravatar image

How to delete a file in linux securely and permanently, so it can never be recovered?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by zoltanh721
close date 2014-06-27 17:41:14.439063

4 Answers

Sort by » oldest newest most voted

answered 2011-09-29 00:59:57 -0500

shanks gravatar image
$ yum install srm
$ srm myfile.txt

srm removes each specified file by overwriting, renaming, and truncating it before unlinking.
This prevents other people from undeleting or recovering any information about the file from the command line.

Instead of just overwriting your files with random data, it uses a special process – a combination of random data, zeros, and special values developed by cryptographer Peter Gutmann – to really, really make sure your files are irrecoverable.

edit flag offensive delete link more

answered 2011-10-04 01:47:03 -0500

tezcatl gravatar image

It's interesting too scrub, and very useful if you want to, well, scrub deeply a file, a whole partition/disk before creating an encrypted partition, or your free space. And it is actually very fast.

edit flag offensive delete link more

answered 2011-09-29 04:48:50 -0500

satyaakam gravatar image

or use the command shred

edit flag offensive delete link more

answered 2011-11-16 18:22:01 -0500

bct gravatar image

updated 2011-11-16 18:23:52 -0500

As tezcatl says scrub and dd are good choices. If you're wiping a whole disk make sure to change the bs=BYTES option (see `man dd') and experiment a little (depends on the HDD), as this can speed the process up e.g.

dd bs=8M if=/dev/zero of=/dev/hdd

There is also no need to overwrite something more than once [1].


edit flag offensive delete link more


This is actually a good option on solid state media like USB pendrives, however I wonder if forensics software like Photorec [1] could recover the "erased" file in this type of media.


tezcatl gravatar imagetezcatl ( 2013-07-04 20:28:43 -0500 )edit

It could not. It's possible that organizations like the NSA could recover it if they wanted the data badly enough and could spend a bunch of money working on it and it was only overwritten once, especially with just zeros, but that will certainly foil any recovery software.

As for the "Gutmann Method", yes, you don't need 35 passes, but I would not trust 1 pass with zeros to foil the NSA. (But it would make their job hard.) Maybe two passes with random data would foil them completely, however.

dougmc gravatar imagedougmc ( 2014-03-09 00:02:25 -0500 )edit

Question Tools

1 follower


Asked: 2011-09-29 00:33:39 -0500

Seen: 5,978 times

Last updated: Feb 09 '12