shred
Files and directories
Usage
shred -u [file]Overwrites a file's bytes before deleting it, but on SSDs and copy-on-write filesystems such as btrfs or APFS the old blocks may survive, so full-disk encryption is the real answer.
Common flags
| Flag | Meaning |
|---|---|
| -u | Remove the file after overwriting it |
| -n | How many overwrite passes; the default is 3 |
| -z | Finish with one pass of zeros so the shredding is not obvious |
| -v | Show the progress of each pass |
| -s | Shred only the first N bytes |
Examples
shred -uvz secret.keyOverwrites, zeroes and then deletes.
sudo shred -vn 1 /dev/sdbOne pass over a whole disk.
rm -P secret.keyThe nearest thing macOS ships.
Moving, deleting and finding. Some of these do not ask twice, which is why -i becomes a habit.
How to read this
- Square brackets [ ] mark a part you may leave out.
- An ellipsis … means you can list more than one.
- Flags are case-sensitive — in some commands -r and -R do different things.
Questions
Q. What does shred do?
Overwrites a file's bytes before deleting it, but on SSDs and copy-on-write filesystems such as btrfs or APFS the old blocks may survive, so full-disk encryption is the real answer.
Q. How do I type it?
shred -u [file] — square brackets mark the parts you can leave out.
Q. How many flags are worth knowing?
5 are listed here; the full set is in man shred. This command sits under Files and directories.
Related commands
man page: man shred