Delete a File with Overwrite (rm -P)
Use rm -P to overwrite a sensitive file before removal instead of just unlinking it.
Run `rm -P path/to/file` — the file is overwritten and then deleted, defeating basic undelete tools.
01Command
Command
$ rm -P ~/Documents/sensitive.txt02What it does
A normal rm only unlinks the file; the blocks stay on disk until reused, which is how simple recovery tools can resurrect deleted files. rm -P overwrites the data first, then removes the file. On modern SSDs with APFS, wear-leveling and snapshots make this best-effort rather than a guarantee — the strongest everyday protection is keeping FileVault enabled so nothing on disk is recoverable without the key anyway.
03Risk
!Warning: The file is gone for good — there is no Trash and no undo with rm.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- rm — remove files or directories (macOS man page)Evidence: Documents rm -P: overwrite regular files before deleting them so the data cannot be recovered by simple tools.
Last verified: 2026-09-18 · Category: Security & Privacy