Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the sysinternals suite for windows there is this nifty sdelete tool for securely deleting individual files as well as overwriting unallocated disk space with randomness or zeroes ( the -c or -z option).

I know there is a similar function in OSX in the disk manager but I'd like to add this as a cron job in order to know that all my deleted files really are deleted. This is also a good way to optimize virtual machine disk usage.

Are there any command line based tool that is equivalent to sdelete on osx?

share|improve this question
up vote 3 down vote accepted

With a little more searching:

man diskutil -- Modify, verify and repair local disks

secureErase [freespace] level device
Securely erase a disk or freespace on a mounted volume.
Level should be one of the following
1 - Single pass randomly erase the disk.
2 - US DoD 7 pass secure erase.
3 - Gutmann algorithm 35 pass secure erase.  Ownership of the affected disk is required.
share|improve this answer
Same comment as above... – 8DH May 1 '11 at 19:21
I'll try that out. Thanks. – 8DH May 2 '11 at 10:45

man srm srm - securely remove files or directories

On the Mac, just use the menu “Finder▸Secure Empty Trash”.

The command line equivalent is “srm”. Like this: 「srm -r -s dir_path」. The “-r” means all content in the dir, including sub dir. The “-s” means just overwrite once.

share|improve this answer
Thanks, but does it also overwrite unallocated space? – 8DH May 1 '11 at 19:19
srm and BCWipe only do secure file deletion. diskutil has an option which will "overwrite unallocated space" just like Disk Utility and the "Erase Free Space" option. diskutil secureErase freespace 1 device Open terminal and type: man diskutil then scroll down to secureErase ( or do a find ) Read well. -Bill – broomdodger May 2 '11 at 5:36
I'm sorry. Thanks for the help. – 8DH May 2 '11 at 10:44

shred (part of GNU coreutils) and wipe.

Quote from shred's manual; applies to all tools:

CAUTION: Note that shred relies on a very important assumption: that the file system overwrites data in place. This is the traditional way to do things, but many modern file system designs do not satisfy this assumption.

To wipe free space, fill the filesystem like this:

# repeat 3 times
for x in {1..3}; do
    dd if=/dev/urandom of=/tmp/foo bs=8M
    rm /tmp/foo
share|improve this answer
Thanks for the ponter but if I understand it right shred and wipe both erase existing files. The sdelete feature I'm looking for in an equivalent osx cmd line tool is to overwrite all unallocated space on disk with random bits. – 8DH Apr 27 '11 at 10:51
@8DH: In that case, just create a really big file containing random data. It's what sdelete does. – grawity Apr 27 '11 at 10:52
@8DH: Unrelated tip: On Windows, you don't need sdelete; you can use `cipher /w:C:` to wipe free space. – grawity Apr 27 '11 at 10:54
Nice. I'll try that. Thanks. – 8DH Apr 27 '11 at 10:57

If you have MacPorts installed you can compile bcwipe.

080938 port info bcwipe
bcwipe @1.7-7 (sysutils, security)
Variants:             universal

Description:          The BCWipe software is intended to give you a confidence
                      that your deleted files cannot be recovered by an intruder.
                      BCWipe repeatedly overwrites special patterns to the files
                      to be destroyed. BCWipe for UNIX offers two wiping schemas:
                      US DoD 5200.28-STD standard and Peter Gutmann's 35 pass

Platforms:            darwin
License:              unknown
share|improve this answer
Very interesting. I'll try it out. Does it have the same limitations as described by @grawity? – 8DH May 1 '11 at 19:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .