$linuxjunkies
>

shred(1)

Securely overwrite files to make them unrecoverable before deletion.

UbuntuDebianFedoraArch

Synopsis

shred [OPTION]... FILE...

Description

shred overwrites the specified files repeatedly with random data before removing them, making recovery via forensic techniques extremely difficult or impossible. By default it overwrites files 3 times with random patterns, then once with zeros.

shred is useful for securely destroying sensitive data like passwords, keys, or confidential documents. Note that shred may not work reliably on all filesystems (especially journaling filesystems) and provides best-effort security, not absolute guarantees.

Common options

FlagWhat it does
-f, --forceChange permissions to allow writing if necessary; suppress error messages
-u, --removeTruncate and remove the file after overwriting
-v, --verbosePrint progress information about which files are being overwritten
-n NUM, --iterations=NUMOverwrite NUM times instead of the default 3 times
-z, --zeroAdd a final overwrite with zeros to hide shredding
-s SIZE, --size=SIZEShred SIZE bytes instead of the whole file
--random-source=FILERead random bytes from FILE instead of /dev/urandom
-x, --exactDo not round file sizes up to the next full block

Examples

Securely overwrite secret.txt with verbose output, then remove it completely

shred -u -v secret.txt

Overwrite confidential.doc 10 times plus a final zero pass, then remove it

shred -u -n 10 -z confidential.doc

Shred all .log files in current directory, forcing overwrites even if read-only

shred -u -f *.log

Securely destroy a key file with 5 overwrite passes and verbose progress

shred -u -v -n 5 sensitive_key.pem

Shred only the first 1024 bytes of a large file, then remove it

shred -u -s 1024 large_file.bin

Securely overwrite all temp files matching the pattern with progress output

shred -v /tmp/temp_*

Related commands