Random password generator (BASH)

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1483
Joined: Fri Aug 29, 2003 8:39 pm

Random password generator (BASH)

Post 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).
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply