Home·Terminal commands

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

FlagMeaning
-uRemove the file after overwriting it
-nHow many overwrite passes; the default is 3
-zFinish with one pass of zeros so the shredding is not obvious
-vShow the progress of each pass
-sShred only the first N bytes

Examples

shred -uvz secret.key

Overwrites, zeroes and then deletes.

sudo shred -vn 1 /dev/sdb

One pass over a whole disk.

rm -P secret.key

The 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