Skip to content

Instantly share code, notes, and snippets.

@niksumeiko
Created June 30, 2013 10:16
Show Gist options
  • Save niksumeiko/5894627 to your computer and use it in GitHub Desktop.
Save niksumeiko/5894627 to your computer and use it in GitHub Desktop.
Mac Terminal command that securely removes files from Trash using incredibly secure 35-pass method. That basically means that first the data is removed, then written over 35 times using randomly generated patterns, making recovery quite literally impossible.
##
# Command to empty Trash with 35-pass security method. This is the most secure deletion,
# so you will not be able to recover any file deleted with this method.
# Replace <MAC_USER> with your Mac username.
##
srm -rfv /Users/<MAC_USER>/.Trash/*
##
# Command to empty Trash with 7-pass security method that meets the
# US Department of Defense standard for securely erasing data.
# Notice '-m' flag in the command that applies "medium" removal security (7-pass).
# Replace <MAC_USER> with your Mac username.
##
srm -rfv -m /Users/<MAC_USER>/.Trash/*
##
# Command that forcibly & securely removes all locked or owned files with Super User
# permissions. This is as secure (35-pass) and as ‘dangerous’ as it gets because of
# the superuser access. Use with extreme caution and do not use this is unless you
# know what you're doing and why you're doing it.
# The '-f' flag adds force removal of the files, so you'll never get any notification
# when programm is deleting files.
# Replace <MAC_USER> with your Mac username.
##
sudo srm -rf /Users/<MAC_USER>/.Trash/*
##
# Any of the command above could be added into your Mac user .profile file as an alias
# to make removal command just shorter.
#
# If you don't have .profile file in the root folder of your user, just create it.
# Replace <MAC_USER> with your Mac username.
sudo touch /Users/<MAC_USER>/.profile
# If you already have .profile file or just created, open it for edition:
sudo nano /Users/<MAC_USER>/.profile
# And add any of the commands above as an alias:
alias secureEmptyTrash="srm -rfv /Users/<MAC_USER>/.Trash/*"
alias emptyTrash="srm -rfv -m /Users/<MAC_USER>/.Trash/*"
alias forceEmptyTrash="sudo srm -rf /Users/<MAC_USER>/.Trash/*"
# To save and close .profile file edition mode, hit 'CTRL + O' keys on your keyboard,
# then hit Enter (/return) key to overwrite and last 'CTRL + X' to exit edition mode.
# Reload your .profile file after its being edited. That makes sure your newly created
# commands aliases are available in the Terminal.
. ~/.profile
# And you're ready to use aliases any time you open Terminal:
secureEmptyTrash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment