Secure deletion of files (Linux)

December 17, 2023 - Reading time: ~1 minute

When removing files from a hard drive, it is recommended to securely delete them so when the hard drive is reused, no fragments of old files remain on the drive.

The way to do this is to use shred. To find all the files in the directory tree, you use find. The whole bash one liner is below:

find -type f -exec shred {} \;

You can add switches to the shred command, I recommend the ones below

-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

-n, --iterations=N
overwrite N times instead of the default (3)

LazyCoderOZ

I am a Linux guy, been around for 20+ years using Linux as my daily driver.
This is my blog on my discoveries and notes so I don't forget how I have done things :)