Learn the Proper Use of the Linux Shred Command

When you don't want anyone to see the files you delete

Shred is one of four Linux commands that sound similar but are not the same—shred, wipe, delete, and erase.

Use shred to erase a single piece of data permanently. The information, which you identify, is overwritten by 1s and 0s several times, which permanently erases the data. This approach is unlike similar commands that erase data but leave it retrievable under certain circumstances.

Document emerging from paper shredder
 Zigy Kaluzny / Getty Images

Usage of 'shred'

The command takes the following format:

shred [option] filename

The command's options include:

  • -f: Changes permissions to allow writing if needed.
  • -n=x: Overwrites x times instead of the default, which is three times.
  • -s=x: Specifies the number of bytes, x, to shred.
  • -u: Truncates and removes files after overwriting.
  • -v: Shows verbose information about the progress.
  • -x: Do not round file sizes up to the next full block.
  • -z: Adds a final overwrite with zeros to hide shredding.
  • -u: Removes the file after overwriting.

Places Shred Doesn't Work

Shred relies on an important assumption—that the file system overwrites data in place. This approach is customary, but some file systems do not satisfy this assumption. Shred will not work as expected in:

  • Log-structured or journaled file systems, such as those supplied with AIX and Solaris (and JFS, ReiserFS, XFS, and Ext3).
  • File systems that write redundant data and carry on even if some writes fail, such as RAID-based file systems.
  • File systems that make snapshots, such as Network Appliance's NFS server.
  • File systems that cache in temporary locations, such as NFS version 3 clients.
  • Compressed file systems.

Also, file system backups and remote mirrors may contain copies of the file that cannot be removed, and that could allow a shredded file to be recovered later.

Was this page helpful?