How to secure file deletion with shred

· Category: Linux

Short answer

shred overwrites files repeatedly to make recovery difficult before optionally deleting them.

Steps

  1. Overwrite a file:
shred -v -n 35 file.txt
  1. Overwrite and remove:
shred -vu -n 35 file.txt
  1. Overwrite a device:
sudo shred -v /dev/sdb

Tips

  • Use -z to add a final overwrite of zeros to hide shredding.
  • Modern SSDs and filesystems (journaling, CoW) may still retain data.
  • Full disk encryption is more reliable than shredding for sensitive data.

Common issues

  • shred is ineffective on copy-on-write filesystems like Btrfs and ZFS.
  • RAID and logical volumes may store data redundantly.