How to Securely Wipe the Free Space on Your Mac

Securely Wipe the Free Space on Your Mac Using the Command Line
Before wiping the free space on your Mac using the command line, back up your data.

Once you’ve backed up your data, open the Terminal app from the Applications > Utilities folder.

Then, type the following command at the prompt and press Enter.

diskutil secureErase freespace 4 /Volumes/Macintosh\ HD
Make sure you include “freespace” in the command. This indicates you are only erasing the free space on the drive and not the entire drive.

The number “4” indicates the wipe level performed on the drive’s free space. You can use “4” for the wipe level, or select a different option from the following list:

0 – Single-pass zero-fill erase.
1 – Single-pass random-fill erase.
2 – US DoD 7-pass secure erase.
3 – Gutmann algorithm 35-pass secure erase.
4 – US DoE algorithm 3-pass secure erase.
The more passes you do when wiping the free space, the longer the process takes.