Useful Commands

January 30, 2010

Here is a link to a page with some very useful Unix commands.  Also they provide the equivalent DOS commands when possible.  I think it’s pretty neat, so have fun looking around.


January 9, 2010

If you were to tell me that you have never had to create a password for any kind of electronic account I would think that you lived under a rock or didn’t have a bank account.

I don’t know about you but for me the worst part about having a password for an account is creating one. Sure there are ones that are easy to remember, but are at the same time easy to guess. Such as you birthday or your anniversary. On the flip side, there are passwords that are near impossible to “break”, but they are also damn near impossible to remember. Well I’m not going to talk about how you should go about creating a password. If you really don’t know then I suggest you spend some time on Google or even CNN and NYT.

Instead I will discuss how you can use your computer to generate pretty strong (and “random”) passwords for you.  To do this we will make use of  /dev/urandom, cat, tr, and grep.  Suppose that you must create a password that has length 8 and contains at least one of the following characters !,*,&, and #, in addition to alphanumeric characters.  Well here is what you would enter to have your system create a list of, say 4, such passwords.

cat /dev/urandom | tr -dc 'a-zA-Z0-9!*&#' | fold -w 8 | head -n 4 | grep -i '[!*&#]'

Now instead suppose that your password did not have to have one of !, *, &, or #.  Then instead you could run:

cat /dev/urandom | tr -dc 'a-zA-Z0-9!*&#' | fold -w 8 | head -n 4

In addition to using /dev/urandom you could also use /dev/random for an even more secure password. For more information on this (and other aspects) go and read this post. It should answer some, if not most, of your questions.

To lean more about head and fold just go and read their man pages.  They are pretty straight forward.

“Shredding a Directory”

January 2, 2010

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.