How To Use The Shred Command In Linux

While you can use the dd command to overwrite your files, you can also use shred. Shred by default will overwrite your files 3 times and is designed to make it very hard to recover those files. There are several options you can use such as how many times you wish to overwrite the specified file or files, how many bytes, etc. Here are the available options below.

Shred Command Usage

Usage: shred [OPTIONS] FILE

-fChange permissions to allow writing if necessary
-nOverwrite N times instead of the default (3)
-sShred this many bytes (suffixes like K, M, G accepted)
-uTruncate and remove file after overwriting
-vShow progress
-xExact do not round file sizes up to the next full block
-zAdd a final overwrite with zeros to hide shredding
–helpTurn off header (shows interval and command)
–versionDisplay help and exit

Shred Command Examples

Here is an example of using the shred command to remove a file and overwrite it 3 times.

shred -f -u -v ~/randomfile

Here is another example, this time overwriting the data 5 times instead of the default 3 times.

shred -f -u -v -n 5 ~/randomfile

Last but not least, here is an example that tries to hide the fact that a file was shredded, this will add an extra pass with all 0s.

shred -f -u -v -n 5 -z ~/randomfile

Thanks for reading. Please don’t forget to like, comment, or share. Thanks for the support!

Leave a Reply

Protected with IP Blacklist CloudIP Blacklist Cloud