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.


July 10, 2009

Well today I decided to learn Bash.  One of the tutorials (though not all that great) had a pretty good introduction on some terminal commands.  The best job was done with the echo command.  First I’ll show some examples then explain what they each do.

  • echo "hello     world"
  • echo hello     world
  • echo “Number2 Atoms Zzz…” | tr ” ” “\n” | sort

The first line will print “hello      world” to the screen, while the second will print “hello world”. Notice how the extra space disappeared.  This is because the string is not in quotation marks.  The final example will display




This is due the fact that the tr command will replace all the spaces with new lines, then sort will sort them in lexicographic order. I’ll hopefully explain more about tr in later post since it seems that it can use regx. But basically echo prints whatever follows it to the screen. Finally the pipeline, ‘ | ‘, will cause the result of running the previous command to be used as the input for the following command.  This to will be talked about later, mainly because I am tired and am going to end this post now.