Linux Shred Command Examples

Linux Shred Command Examples

Linux Shred Command overwrite the specified FILE(s) repeatedly, in order to make it harder for even very expensive hardware probing to recover the data.

CAUTION: Note that shred relies on a very important assumption: that the file system overwrites data in place. This is the traditional way to do things, but many mod‐
ern file system designs do not satisfy this assumption. The following are examples of file systems on which shred is not effective, or is not guaranteed to be effec‐
tive in all file system modes:

* log-structured or journaled file systems, such as those supplied with AIX and Solaris (and JFS, ReiserFS, XFS, Ext3, etc.)

* 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

Linux Shred Command Examples

Shred file(s)

Overwrite, delete, verbose:

shred -uv file1.txt file2.txt file3.txt

Shred partition on disk

shred /dev/hda2

Shred Directory Example

Bi itself shred command doesn’t have option for recursive shredding files in directory. So we can use find command:

find <dir> -type f -exec shred -uv {} \;


Shred Command Options

-f, –force
change permissions to allow writing if necessary

-n, –iterations=N
overwrite N times instead of the default (3)

get random bytes from FILE

-s, –size=N
shred this many bytes (suffixes like K, M, G accepted)

-u truncate and remove file after overwriting

like -u but give control on HOW to delete; See below

-v, –verbose
show progress

-x, –exact
do not round file sizes up to the next full block;

this is the default for non-regular files

-z, –zero
add a final overwrite with zeros to hide shredding

–help display this help and exit

output version information and exit


Leave a Reply

Your email address will not be published. Required fields are marked *