Page 1 of 1

Random password generator (BASH)

Posted: Fri Mar 15, 2013 1:28 pm
by ^rooker
NOTE: Basically, this post here's a copy/summary of Nixcraft's "HowTo: Linux Random Password Generator Command" on cyberciti.biz:

In order to conveniently generate random passwords for accounts, add the following function code to your "~/.bashrc":

Code: Select all

genpasswd() {
    local l=$1
        [ "$l" == "" ] && l=16
        tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}
Now the command "genpasswd" will generate a 16-digit random password with characters from: A-Z, a-z, 0-9 and underscore "_".

Thank you ver much Nixcraft for this nice howto (and therefore tool).