Wednesday, June 5, 2013

Generate Random Password on Linux

1. Past this following function into your linux .bashrc

genpasswd() {
 local l=$1
        [ "$l" == "" ] && l=20
       tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}

2. Execute command:
genpasswd
genpasswd 16 (16 bit)
genpasswd 32 (32 bit)

and so on.

Note: in Linux, .bashrc is where you may define your own function/command. You may need to execute this command after making changes to .bashrc:
source .bashrc




No comments:

Post a Comment