23

My Question is I want to erase a file in OS X Securely (like the function of "Secure Empty Trash") so that, the file cannot be recovered by using recovery tools. I don't want to empty the trash.

It is possible to erase Files Securely in OS X without moving the file to Trash ?

[Note: Use caution applying old tools or methods to new systems.]

Apple has deprecated all the tools (as well as secure empty trash) that used to overwrite files based on magnetic disk storage considerations. SSD don’t erase the underlying storage when the os deletes a file, so use encryption (which is now hardware accelerated and the default for all macOS systems).]

0

4 Answers 4

32

On macOS (Monterey and newer) this erase flag does nothing.

On OS X shipping when this question was asked and for a good while, could use the terminal command rm with the -P option:

[Option -P will] 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.

If you're not handy with the Terminal, just:

  1. Open the Terminal.app (Found in /Applications/Utilities).
  2. Type cd and drag the folder which contains the file you want to delete, to the terminal window.
  3. Type rm -P FileName.extension and hit Enter

If erasure is important, store your files on an encrypted volume so that any erasure is secure and they are secure at rest. For the overwrite rm option, check for text like this in the manual page (eg man rm)

-P This flag has no effect. It is kept only for backwards compatibility with 4.4BSD-Lite2.

2
  • 9
    Or combine step 2 and 3 by typing rm -P followed by directly dragging the file into the terminal window. It's also worth mentioning that depending on the sector/cluster allocation process it is usually not guaranteed that the whole file will be overwritten. If you really care about these things use FileVault 2 to encrypt the whole drive.
    – nohillside
    Commented Jul 27, 2012 at 13:59
  • 12
    in more recent versions of macos (eg monterey) -P doesn't do anything; according to the man page -P This flag has no effect. It is kept only for backwards compatibility with 4.4BSD-Lite2.
    – ccpizza
    Commented May 28, 2022 at 21:41
17

srm is another shell utility for deleting files securely. It uses the 35-pass Gutmann algorithm by default, but -s (overwriting files with random data once) is faster and should be secure enough for most purposes.

4
  • 1
    In fact, choosing "Secure Empty Trash" in Finder invokes srm.
    – lupincho
    Commented Jul 29, 2012 at 16:23
  • @lupincho How do you choose that? I’ve never seen it before Commented Jun 21, 2021 at 23:09
  • 4
    @unbeatable101: it is no longer available in recent versions of MacOS
    – lupincho
    Commented Aug 19, 2021 at 13:58
  • IIRC it's not effective, and maybe not safe, to use something like that with an SSD
    – Ian Dunn
    Commented Nov 9, 2023 at 17:08
8

If you want to make sure that your files, deleted or otherwise, cannot be recovered, just turn on FileVault to encrypt your disk.

Multiple erases or writes on SSDs do not make the file "more" erased.

(I realise this is an old question.)

-3

The securely delete command overwritten the areas on the storage medium. In OS X El Capitan 10.11 it was still accessible via the terminal. It was called srm - and has disappeared since macOS Sierra 10.12

The -P option ensures that when deleting the memory areas are overwritten three times before the memory space is released. For example, rm -P Desktop/File.txt deletes the file File.txt from the desktop. The additional option -R also removes folder contents and subfolders (as well as their contents)

rm -RP ~/Desktop/[Directory/File]

Deletes folders and their contents. To avoid typing errors, enter rm -RP including a space at the end.

3
  • 1
    Does rm securely delete files as the OP asks?
    – mmmmmm
    Commented Jun 21, 2021 at 9:42
  • 3
    -P is already mentioned in the accepted answer. Nowadays, as apple.stackexchange.com/a/422756/9058 explains, neither srm nor rm -P will ensure that data actually gets overwritten.
    – nohillside
    Commented Jun 21, 2021 at 9:46
  • And that is the reason to vote me down now?
    – BabyBoy
    Commented Jun 22, 2021 at 6:46

You must log in to answer this question.

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