1

According to the rm man page rm -P ... overwrites items three times to delete them securely:

-P            Overwrite regular files before deleting them. Files are
                overwritten three times, first with the byte pattern 0xff,
                then 0x00, and then 0xff again, before they are deleted.

Is it possible to single pass secure delete items with rm ...?

Notes:

  • I don't want to use srm! I need rm only, please.
  • I use a MacBook with an HDD and macOS 10.13.
  • 1
    Why do you not want to use srm? This is what's it's designed for. – Allan Mar 12 '18 at 13:52
2

No, that is not possible with the standard rm command.

You could download the rm source code (rm.c) from opensource.apple.com and edit the rm_overwrite() function to only do a single pass.

Or you could use an alternative program that overwrites the file, and then afterwards use rm to delete it. Such an alternative program could just be to use cat or dd to copy bytes from /dev/urandom or /dev/null over the file.

2

You can't have rm do something that it doesn't have the capability of doing. On the other hand srm was designed expressly for this purpose. So, how do you get rm to do something that srm does out of the box?

Make an Alias

If you want to "use" (the command; not the actual program) rm to do a single pass, use an alias. To do this, you will need to have srm installed on your system (available in MacPorts).

$ alias rm="srm -s"

Now, anytime you issue the command rm it will actually be calling srm with the -s flag for "single pass overwrite".

Usage example: Suppose you have a directory called foo with a number of files that you want to delete. Issue the command

$ rm -rf foo

and what will actually be executed is:

$ srm -s -rf foo

Make the Alias permanant

Edit your ~/.bash_profile and add the alias entry. Restart your bash session and the "one pass rm command" will now be available.

  • 1
    Isn't srm available in the default installation of High Sierra? In 10.9-10.11 it is... – klanomath Mar 12 '18 at 16:26
  • 2
    srm is not in 10.12 – Mark Mar 12 '18 at 16:34

You must log in to answer this question.

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