shred Command Examples in Linux

Before encrypting a device, it’s a good idea to overwrite its contents with random data or all zeros. This ensures that no sensitive data from past use remains on the device. The shred command can be used to securely wipe a storage device in this manner.

shred Command Examples

1. Overwrite a file:

# shred file

2. Overwrite a file, leaving zeroes instead of random data:

# shred --zero file

3. Overwrite a file 25 times:

# shred -n25 file

4. Overwrite a file and remove it:

# shred --remove file

Conclusion

Digital shredding in Linux is done with the shred command. Its usage is very similar to the rm command, though in terms of removal, shred is much more thorough. The shred command overwrites the file 25 times (which is adjustable by using the -n # option) so it is impossible to re-create it. Before using shred, however, read its man page, as its success rate is highly dependent on the type of filesystem you’re using.

Related Post