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 man shred
Shows the version of the program:
Number of rewrite cycles (by default, if not specified, then 25):
Change the file write permissions, if necessary:
By default, shred does not delete the file, but only overwrites it with random data, if specified, it will be deleted:
Shows progress indicator:
Clears the specified number of bytes, you can specify the size in K, M and G:
Add zeros at the end of the file to hide the shuffle:
Do not round file sizes to the next whole block, the default for non-regular files:
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:
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