LKBEN11129: How to use shred to delete files.


You need to realy delete your data.


You want to be sure no one can recover your deleted files.


Deleting a file or reformatting a disk does not destroy your sensitive data. The data can easily be undeleted. That’s good if you accidentally deleted something, but what if you are trying to destroy financial data, bank account passwords, or other classified company information. A god tool to erase sesitive data is Shred. Although it has limitations, the shred command can be useful for destroying files so that their contents are very difficult or impossible to recover. Shred accomplishes this by repeatedly overwriting files with data patterns designed to do maximum damage so that it becomes difficult to recover data even using high-sensitivity data recovery equipment.

Note :Deleting a file with the rm command does not actually destroy the data, it merely destroys the index listing the location of the file and makes the file’s data blocks available for reuse. A file deleted with rm can be easily recovered using special utilities or commands if its freed data blocks have not yet been reused, but on an active system with a nearly full hard disk drive, freed space can be reused in a matter of minutes or even seconds.

Shred Syntax

    shred [option(s)] file(s)_or_devices(s)

Available Options

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

-n, iterations=N     - Overwrite N times instead of the default (25)

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

-u, remove         - truncate and remove file after overwriting

-v, verbose         - show progress

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

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

-shred             - standard output

-help             - display this help and exit

-version         - output version information and exit

Shred Examples

1) The following command can be used to securely destroy multiple files (in this example named file1, file2 and file3).

    shred file1 file2 file3

2) The following command destroys data on the seventh partition on the first HDD

    shred /dev/hda7

3) To erase all trace of the filesystem you created on the floppy disk in your first drive.  

    shred -verbose /dev/fd0

4) To erase all data on a selected partition of your hard disk.

    shred -verbose /dev/sda5


The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.

Latest update: 05/10/2020 | Comment: