Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a directory on a Mint install that I want to wipe clean (not just delete the pointers, actually zero the info off the drive). is it possible to clear the data by using dd? For example, if the files I want to erase are at /folder/folder1/*, can I execute dd if=/dev/zero of=/folder/folder1 bs=1k and have that zero all files in that directory? Also, if I have subdirectories, will it work recursively to zero all subfolders as well?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

You can use find and dd together to recursively write over files, one at a time:

find /folder/folder1 -type f | while read line; do dd if=/dev/zero of=$line bs=1k count=1024; done

Then you can just rm -rf the parent directory:

rm -rf /folder/folder1

This will by no means be a quick process, but it will get the job done. There are certainly better tools out there than using dd for this.

share|improve this answer

You cannot use dd for folder, which is for devices such as a partition or a file. If it is Ubuntu, you should install shred, which is designed for what you want to do.

Shred works on files only, so you want to do:

find /folder -type f -print0 | xargs -0 shred

You can use shred on partitions as well.

There are many other tools if you are not on Ubuntu. shred may be available for other distros as well.

You can also just google for deleting files securely in Linux, or something like that, to find more tools that may better suit your needs.

share|improve this answer
    
mint has different code bases, with some based on ubuntu/debian, that is why i am not too clear what packages are available for yours. i am pretty sure shred is available for the current mint. –  johnshen64 May 10 '12 at 15:01
    
Thanks! It is noteworthy that shred only works on files, not on folders. I solved this by executing find /folder/folder1 -type f | xargs shred –  ewok May 10 '12 at 15:03
    
ah ok, thanks for the feedback! –  johnshen64 May 10 '12 at 15:05
    
To be safe, you want to use print0 as a find option and pass -0 to ´xargs` @ewok –  slhck May 10 '12 at 15:35

I use srm, which is in the secure-delete package on Ubuntu and Debian. sudo apt-get install secure-delete to install it, then srm -r $directory to securely remove an entire directory tree. srm won't overwrite non-regular files, but it will (by default) rename all files and directories to a random value before unlinking them.

You can use the -z flag to have it write zeros for the last pass and -v to see its progress. See man srm for more information.

share|improve this answer

No, you can't use dd to securely delete a directory, but you can use wipe.

wipe repeatedly overwrites special patterns to the files to be destroyed, using the fsync() call and/or the O_SYNC bit to force disk access

share|improve this answer
2  
... can you elaborate a bit? –  ewok May 10 '12 at 14:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.