Wednesday, February 15, 2012

Linux Random Password Generator

I was looking for a random password generator tool to use it while creating oracle users. And found a cool solution that works on a linux OS.
It works using linux urandom function:
tr -dc A-Za-z0-9_ < /dev/urandom | head -c 8 | xargs

Here, i'm using head -c 8 to show me 8 character long password.

If you feel that the command is tough to memorize. Then just create a function and call it!!!
genpasswd() {
        local l=$1
        [ "$l" == "" ] && l=16
        tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs

Now simply call it with your intented string length..
genpasswd 8


Isn't it cool!!! :)

No comments: