“Shredding a Directory”

Well  you are all familiar with the shred command right?  Well if not then I suggest you read the post at this link.  It does a better job than I could ever hope to.  That and I’m just plain lazy, but mostly because it is an amazing post.

So at this point you should have played with the command a little and noticed that it doesn’t let you shred directories.  Well here is a little ‘hack’ to get around that, say hello to the find command.  I’ll probably talk more about this command later, but now I’ll just explain how it can be used in conjunction with shred.

Say you have a directory on your Desktop call Stuff, and you would like to shred it because it contains very sensitive documents (don’t ask me why you stored this on your personal computer).  First go to that directory and do the following:

cd ~/Desktop/Stuff
find -type f -execdir shred [options] '{}' \;
cd .. && rm -rf Stuff

In the [options] field, I normally put either -z or -uz, but that’s just something I like to do.  First of all you should know what the first line here does, so I won’t explain it at all.  The last line first moves you back to the Desktop and then the rm command is used to remove files (in the insecure sense).  Here the -rf options says that you want to run rm recursively (on all subdirectories) and to force remove files.  Now for the second line, where most of the work is done.

find -type f will list all of the normal files (for simplicity non-directories) in the current directory.  After this the -execdir option says to run the following command (shred in this case) on all of the files that were previously found.

There you have it, a nice way to “securely” a directory.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: