srm - macOS


srm is a command used on macOS to securely remove files by overwriting their contents multiple times, making it difficult to recover the data using common data recovery tools. It is particularly useful for sensitive or confidential information that needs to be securely disposed of.


srm [-dRUfv] [-z] [-n wipe_count] file1 [file2...]


  • -d: Enable debugging mode, printing additional information.
  • -R: Recursively remove directories and their contents.
  • -U: Remove the file without overwriting its contents.
  • -f: Force the removal of files without confirmation.
  • -v: Enable verbose output, showing the progress of the removal.
  • -z: Add zeroes to the end of the overwritten data, making it harder to recover.
  • -n wipe_count: Specify the number of times to overwrite the file contents (default: 3).


  • Simple file removal:

    srm /tmp/myfile.txt
  • Recursive directory removal:

    srm -R /tmp/mydirectory
  • Silent removal without overwriting:

    srm -U -f /private/secrets.txt
  • Verbose removal with multiple overwrites:

    srm -v -n 7 /etc/myconfig.ini

Common Issues

  • Permission errors: If the user does not have write permissions to a file or directory, srm will fail to remove it.
  • Insufficient disk space: If there is not enough free disk space to overwrite the file multiple times, srm will fail.


srm can be combined with other commands to create automated scripts for securely removing files in various scenarios. For example:

  • Scheduled file removal: Create a cron job to run srm on a regular basis to remove temporary files or logs.
  • Post-installation cleanup: Add a call to srm to a post-installation script to remove installer files or logs after a software installation.
  • rm: Basic file removal command.
  • shred: Another command for securely removing files.
  • xargs: Command used to combine multiple commands into a single pipeline.