So, long story short, I have some, er, sensitive data that I'd like to protect from people trying to snoop around. Let's say it's in a folder on my desktop called My Secrets
.
However, I'd like to retain some sort of method to destroy this data to make it unrecoverable, in such a way that it is impossible to recover and that there is no proof that this data even existed in the first place.
I'd like to be able to preserve my Ubuntu installation and any/all non-sensitive data, so a complete nuke (sadly) isn't an option.
How can I achieve this in Ubuntu?
Ideally, I'd also like to be able to trigger this deletion at the drop of a pin, from which point there is no stopping the (at the very least partial) destruction of my data. I'm also willing to use a solution that requires setup (for, say, any future data that needs storage).
shred
from GNUcoreutils
was specifically designed for this purpose.From
man shred
:shred
actually reads random bytes from/dev/urandom
and overwrites the files content with those, at the end optionally overwrites the contents by zeroes (from/dev/zero
). So if you want to reinvent the wheel, you can do this by hand but better to useshred
which is optimized already for the task.For example, for any given file
my_secured_file.txt
, you can do:Here:
-v
for verbosity-z
for overwriting the file with zeroes afterwards, to hide shredding-n 5
is for number of iterations, default is 3You can increase the number of iterations if you want although the default is enough or even remove the file (
-u
,--remove
).Check
man shred
.As
shred
operates on files, for doing the operation on all files of a directory (recursively) e.g.my_secret_dir
:Or
find
:Note:
shred
has the caveat that it can't work properly on the journaling, caching, RAID, compressed file systems. Quotingman shred
:In Ubuntu, if you are using
ext4
filesystem which is also a journaling filesystem, the journal mode is the default for metadata, not for data (data=ordered
is the default), so you should get the expected result withshred
-ing unless you changed the default.As a side note, you can find the default filesystem options by:
Example:
The
has_journal
indicates that this is a journaling FS and the default journal option(s) are:Both at once:
Here's an off the wall suggestion: store the sensitive data only in an encrypted, password-locked cloud storage, with no shortcut folder in your computer (i.e. don't install Dropbox or similar, which creates a local mirror of the remote storage) -- just a bookmark in your browser. When you want to remove evidence on your local system of the sensitive data, delete the bookmark and wipe the browser history (or, ideally, use a high security browser variant or setting that automatically secure wipes the history every time you close it). Ten seconds or so, and there'll be no way for anyone to know where to start looking, short of a forensic level complete system search (extremely unlikely unless you're an international spy or child porn trafficker).