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?

4 Answers 4


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.
  • Same comment as above...
    – 8DH
    May 1, 2011 at 19:21

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.

  • Thanks, but does it also overwrite unallocated space?
    – 8DH
    May 1, 2011 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 May 2, 2011 at 5:36

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
  • 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, 2011 at 10:51
  • @8DH: In that case, just create a really big file containing random data. It's what sdelete does. Apr 27, 2011 at 10:52
  • @8DH: Unrelated tip: On Windows, you don't need sdelete; you can use `cipher /w:C:` to wipe free space. Apr 27, 2011 at 10:54

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
Homepage:             http://www.jetico.com/

Platforms:            darwin
License:              unknown
Maintainers:          [email protected]
  • Very interesting. I'll try it out. Does it have the same limitations as described by @grawity?
    – 8DH
    May 1, 2011 at 19:20

You must log in to answer this question.

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