Learn the Proper Use of the Linux Shred Command

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

Shredding paper
Image Source / Getty Images
Was this page helpful?

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

You use shred when you want to permanently erase a single piece of data. The information, which you identify, is overwritten by 1s and 0s several times, which permanently erases the data, unlike the other similar commands that erase data that is retrievable under certain circumstances. 

With the shred command, you can shred a small collection of files whenever you want.

It is an easy way to erase data you don't want anyone to be able to unerase. Ever.

Shred Syntax

shred [OPTIONS] FILE [...]

Options When Using the Shred Command

Use the Shred command to overwrite the specified files repeatedly and make it difficult or impossible for even expensive hardware or software to recover the data. Options include:

  • -f changes permissions to allow writing if needed
  • -n ​(iterations=N) overwrites N times instead of the default (3)
  • -s (size=N) specifies the number of bytes to shred
  • -u truncates and removes files after overwriting
  • -v shows verbose information about the progress
  • -x does 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

Examples of the Shred Command

To enter the names of the exact files you want to shred, use the following format:

shred fileABC.text file2.doc file3.jpg

If you add the option -u, the listed files are shredded and also deleted to free up space.

shred -u fileABC.text file2.doc file3.jpg

Places Shred Doesn't Work

Shred relies on an important assumption—that the file system overwrites data in place. This is traditional, but some file systems do not satisfy this assumption. The following are examples of file systems on which shred is not effective:

  • 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

In addition, 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.