Securely Delete Files with shred

shred overwrites a file with random data multiple times before unlinking it, defeating simple file-recovery tools.

LinuxdeleteshredsecurityLow risk
Run `shred -u -n 3 file` to overwrite a file three times and then delete it.

01Command

Command
$ shred -u -v -n 3 secret.txt

02What it does

Plain rm only unlinks the filename — the data blocks stay on disk until overwritten, which is what recovery tools read back. Options: `-n` passes (3 is the common choice), `-z` writes a final pass of zeros so the file doesn't look shredded, `-u` unlinks after. shred works file-by-file and cannot handle copies that exist elsewhere: snapshots, editor backups, or journaling filesystem copies survive it.

03Risk

RiskLow risk
Requirementscoreutils (default); effective mainly on HDDs — see warning for SSDs
!Warning: On SSDs, wear-leveling means shred may not overwrite the actual flash cells — use the drive's secure-erase feature (e.g. `blkdiscard` or ATA Secure Erase) or full-disk encryption instead.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • shred(1) - Linux manual page
    Ubuntu Manpages · technical · 2026-09-17
    Evidence: shred repeatedly overwrites a file with random data; -n sets the number of passes, -z adds a final zero pass to hide shredding, and -u removes the file afterwards.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions