Shredding data with Shred

Shred – allows you to overwrite the specified file with random data in order to ensure, if necessary, the more difficult process of recovery or the impossibility of data recovery.
On some file systems, data deletion is not guaranteed and the use of shred may not be effective.

The list of possible arguments:
Help program:

--help
man shred

Shows the version of the program:

--version

Number of rewrite cycles (by default, if not specified, then 25):

-n, --iterations=N

Change the file write permissions, if necessary:

-f, --force

By default, shred does not delete the file, but only overwrites it with random data, if specified, it will be deleted:

-u, --remove

Shows progress indicator:

-v, --verbose

Clears the specified number of bytes, you can specify the size in K, M and G:

-s, --size=N

Add zeros at the end of the file to hide the shuffle:

-z, --zero

Do not round file sizes to the next whole block, the default for non-regular files:

-x, --exact

I will give examples of use:

shred -u /dir/dir/file
shred -u -n 35 /dir/dir/file
shred -u -z /dir/dir/file

To delete some files:

shred -u -z -n 30 /dir/dir/file1 /dir/dir/file2 /dir/dir/file3

or you can delete everything by mask:

shred -u -z -n *.txt

Overwriting the entire section with random data:

shred /dev/sda

An example of deleting a key from an encrypted user’s home directory and logging out:

/bin/sh -c '/usr/bin/shred -uf /home/user/.ecryptfs/wrapped-passphrase && /usr/bin/gnome-session-save --force-logout'

See also my article:
Using wipe in Linux

Leave a comment

Leave a Reply