While you can use the dd command to overwrite your files, you can also use shred. Shred by default will overwrite your files 3 times and is designed to make it very hard to recover those files. There are several options you can use such as how many times you wish to overwrite the specified file or files, how many bytes, etc. Here are the available options below.
Shred Command Usage
Usage: shred [OPTIONS] FILE
|-f||Change permissions to allow writing if necessary|
|-n||Overwrite N times instead of the default (3)|
|-s||Shred this many bytes (suffixes like K, M, G accepted)|
|-u||Truncate and remove file after overwriting|
|-x||Exact do not round file sizes up to the next full block|
|-z||Add a final overwrite with zeros to hide shredding|
|–help||Turn off header (shows interval and command)|
|–version||Display help and exit|
Shred Command Examples
Here is an example of using the shred command to remove a file and overwrite it 3 times.
shred -f -u -v ~/randomfile
Here is another example, this time overwriting the data 5 times instead of the default 3 times.
shred -f -u -v -n 5 ~/randomfile
Last but not least, here is an example that tries to hide the fact that a file was shredded, this will add an extra pass with all 0s.
shred -f -u -v -n 5 -z ~/randomfile
Thanks for reading. Please don’t forget to like, comment, or share. Thanks for the support!