Delete a File with Overwrite (rm -P)

Use rm -P to overwrite a sensitive file before removal instead of just unlinking it.

macOSdeleteprivacysecurityHigh risk
Run `rm -P path/to/file` — the file is overwritten and then deleted, defeating basic undelete tools.

01Command

Command
$ rm -P ~/Documents/sensitive.txt

02What 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

RiskHigh risk
RequirementsMost effective for regular files; on SSDs with APFS, wear-leveling means deletion is best-effort — full-disk encryption (FileVault) is the stronger protection.
!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

Last verified: 2026-09-18 · Category: Security & Privacy

06Related solutions