I've just updated to macOS 10.12 and when I try to execute srm in Terminal, it says -bash: srm: command not found.

Is srm removed? How to fix this?

  • 1
    As a side note: srm was a dying project back in the early 2000's. Apple poured some resources into the project and it first appears in 10.3. You should be aware that using srm does not guarantee the data is not recoverable .
    – fd0
    Commented Sep 9, 2016 at 19:54
  • @fd0, can you come up with a better idea or safely removing files from SSD on newer macs? Commented Sep 9, 2016 at 19:57
  • 1
    Full disk encryption, though I do not use it, and rm or empty Trash in the GUI.
    – fd0
    Commented Sep 9, 2016 at 20:07
  • 4
    @NiktinRoman for SSDs srm is no more secure than rm - srm only makes sense for hard disks. I suspect this is the reason it has been removed
    – mmmmmm
    Commented Oct 24, 2016 at 11:24

8 Answers 8


Not yet running macOS 10.12 however under OS X 10.8.5 the man page for srm in the NOTES section states:

Development and discussion of srm is carried out at <http://sourceforge.net/project/?group_id=3297>, which is also accessible via <http://srm.sourceforge.net>.

Now you'd have to download the source code and compile it for yourself. This would require Command Line Tools for Xcode be installed. Not sure if still applicable under macOS 10.12 however, see How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) for details. Or in Terminal use the following command: xcode-select --install

I downloaded the latest source code and it compiled without errors under OS X 10.8.5, although that doesn't mean it will under macOS 10.12 but it's probably the only choice you've got if srm has been removed.

That said, I probably would only srm on rotational HDD's not SSD's.

  • 3
    NB srm is available in homebrew/dupes if you use homebrew. It will complain that MacOS already provides this software. That is not true in Sierra, but in any case to use homebrew to install it you must brew install srm && brew link --force srm
    – kojiro
    Commented Oct 8, 2016 at 22:49
  • 2
    @kojiro doesn't work. "srm was deleted from homebrew/core in commit 7957c4b98" Commented May 10, 2017 at 14:48
  • @AfterWorkGuinness True, Apple ostensibly removed srm because they thought it would destroy people's ssds. github.com/Homebrew/homebrew-dupes/issues/725. I'm somewhat skeptical that they had exactly that reason in mind, but the point remains that secure-delete commands are less useful on ssd than spinning rust. (It probably never occurs to Apple that someone might want to hook up a spinning rust dist.)
    – kojiro
    Commented May 10, 2017 at 14:52

From this comment:

can you come up with a better idea or safely removing files from SSD on newer macs? – Niktin Roman

There's no need for srm; provided that TRIM is enabled on your machine1

TRIM support handles this for you. When you delete a file from your drive, the OS will mark the file space as "not in use" - this applies to any drive. On an SSD, unlike a HDD, a TRIM command is sent to wipe any data in that marked space. This allows your SSD to be able to write data to that marked space as if it was brand new and never used, and skip the traditional deletion process.

If you are looking for more security, turn on FileVault.

Per Apple Support:

Note: With an SSD drive, Secure Erase and Erasing Free Space are not available in Disk Utility. These options are not needed for an SSD drive because a standard erase makes it difficult to recover data from an SSD. For more security, consider turning on FileVault encryption when you start using your SSD drive.

I also advise against using srm because it issues more and unnecessary write operations to the SSD, thus shortening it's lifespan. From the man page:

srm  removes  each  specified file by overwriting, renaming, and
truncating it before unlinking

1 TRIM comes enabled by default if you your Mac came with an SSD preinstalled. if you added an SSD after the fact, then you must enable TRIM by issuing the command sudo trimforce enable in Terminal.

  • 4
    This should be the accepted answer. Commented Jan 12, 2017 at 19:56
  • Does TRIM mark the space this way when you rm the file in the terminal (the deleted file/s will not appear in Trash) or only if you delete "regularly" (move it to the Trash)? Thanks! Commented Oct 19, 2017 at 10:49
  • 1
    "Trash" is just a hidden folder in your home directory - ~/.Trash. So "moving a file to the trash" is just that - moving a file. When you empty the trash is when you actually delete the file. When the file is actually deleted via this method or via rm is when TRIM takes effect.
    – Allan
    Commented Oct 19, 2017 at 11:12
  • 3
    The TRIM command should not be trusted to reliably erase data on an SSD. It simply allows the OS to tell the SSD that certain blocks are no longer in use. It is up to the SSD firmware controller to implement TRIM correctly. Drive manufacturers don't have a good track record here. Even the stronger "secure erase" ATA command is implemented inconsistently, even sometimes reporting success when all data remained on the drive. See cseweb.ucsd.edu/~swanson/papers/Fast2011SecErase.pdf for more info. Commented Jul 11, 2018 at 0:57
  • 1
    @WilliamBudington - your information is woefully out of date. See this post: apple.stackexchange.com/questions/269863/…
    – Allan
    Commented Jul 11, 2018 at 9:33

rm has a -P switch that will overwrite the file three times before deleting. Better than nothing, I suppose.

  • In this use case, this is technically correct. Three times nothing is better than nothing.
    – Rimian
    Commented Aug 13, 2019 at 1:17
  • Here's what the man page says about the -P switch (in macOS 12 Monterey): "This flag has no effect. It is kept only for backwards compatibility with 4.4BSD-Lite2." Commented Jun 23, 2022 at 20:51

UPDATE: In recent macos versions (released in ~2021 or later) this does not work anymore

To securely delete a file/folder on MacOS Sierra without external utilities use rm with the -P switch:

## delete a single file
rm -Pv wikileak1.txt

## delete a folder recursively
rm -Pvrf ~/.wikileaks

From the man page:

 -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.
 -v          increase verbosity

NOTE: In case you installed GNU coreutils from homebrew with the default names, e.g. brew install coreutils --default-names, then, depending on how you configured your PATH, the GNU version of rm could shadow the Mac version at /bin/rm and it won't accept the -P option. Use which -a rm to double-check.

  • In macOS 12, the man page says this about -P: "This flag has no effect. It is kept only for backwards compatibility with 4.4BSD-Lite2." Commented Jun 23, 2022 at 20:54
  • That's correct, in latest macos versions this doesn't do anything.
    – ccpizza
    Commented Jun 26, 2022 at 10:00

Since this question was originally answered two things have happened:

  • homebrew-dupes was merged into homebrew-core
  • srm was deleted from homebrew-core

If you try to install it now it will give you details of the deleting commit and a suggestion to create your own tap if you still need it. I have done so here.

You can install it using Homebrew: brew install khell/homebrew-srm/srm


Use Homebrew, as suggested here:

brew install homebrew/dupes/srm
brew link --force srm

There are plenty of good reasons not to use secure deletion tools (srm, shred, rm -P, etc) on modern systems (with TRIM-enabled SSDs and/or journalled file systems). @Allan's answer in particular is spot on.

However, if you really, really want to restore srm, someone's published a Homebrew tap here that works. Ie:

brew install khell/homebrew-srm/srm
srm secrets.txt

(After you've installed Homebrew, obviously.)


sudo port install srm that will do

  • 3
    It will probably lead to a -bash: port: command not found error, so some more details may be required here.
    – nohillside
    Commented Nov 1, 2016 at 15:30
  • 1
    Install macports: macports.org/install.php
    – eggonlegs
    Commented Nov 15, 2016 at 19:28
  • This is what I did when Macports got uninstalled during some OS upgrade presumably. This is the preferred method in my book, but not a full answer so can't up-vote... oh well. The command I then used sudo srm -RfvD TargetDirectoryToWipe. Not on an SSD... Commented Jun 23, 2018 at 17:39

You must log in to answer this question.

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