shred(1)
Securely overwrite files to make them unrecoverable before deletion.
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
| Flag | What it does |
|---|---|
-f, --force | Change permissions to allow writing if necessary; suppress error messages |
-u, --remove | Truncate and remove the file after overwriting |
-v, --verbose | Print progress information about which files are being overwritten |
-n NUM, --iterations=NUM | Overwrite NUM times instead of the default 3 times |
-z, --zero | Add a final overwrite with zeros to hide shredding |
-s SIZE, --size=SIZE | Shred SIZE bytes instead of the whole file |
--random-source=FILE | Read random bytes from FILE instead of /dev/urandom |
-x, --exact | Do 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.txtOverwrite confidential.doc 10 times plus a final zero pass, then remove it
shred -u -n 10 -z confidential.docShred all .log files in current directory, forcing overwrites even if read-only
shred -u -f *.logSecurely destroy a key file with 5 overwrite passes and verbose progress
shred -u -v -n 5 sensitive_key.pemShred only the first 1024 bytes of a large file, then remove it
shred -u -s 1024 large_file.binSecurely overwrite all temp files matching the pattern with progress output
shred -v /tmp/temp_*