You can use the following command to generate the random password:
tr -dc A-Za-z0-9_ < /dev/urandom | head -c 16 | xargsSample outputs:
1z2G4SVmZOdd4uK4You can create a bash shell function as follows (add to your ~/.bashrc):
Now use genpasswd as follows to create 8 character long password:
genpasswd() {
local l=$1
[ "$l" == "" ] && l=16
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
genpasswd 8
Sample outputs:
Es5Yzf8H
No comments:
Post a Comment