//View Tip #885
Similar Tips
» Get latest stable version of the Linux kernel
» Subtract one file from another
» Random xkcd comic
» List non-system users
» Moved Trac and Subversion repositories to another machine/direct

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Generate a random 8 character password containing a-z, A-Z and 0-9:

egrep -ioam1 '[a-z0-9]{8}' /dev/urandom


View Comments »




Comments 

Add your comment

Comments are currently disabled
On linux I greatly prefer to use pwgen.
Posted 2009-09-16 08:51:00
Mattias
openssl rand -base64 9
Posted 2009-09-16 10:24:55
Andrew
egrep -oam1 '[A-Za-z0-9]{8}' /dev/random

works much better for me.  Dropping the -i option and including A-Z in the regexp speeds it up alot.
Posted 2009-09-16 10:33:36
Rob
< /dev/urandom tr -dc A-Za-z0-9_ | head -c10 | xargs | cat
Posted 2009-09-16 14:58:34
There's a perl program that already does this called makepasswd.  To use:

makepasswd --chars=20

or you can even add it directly to a user:

usermod -p `makepasswd --chars=20` user
Posted 2009-09-21 05:57:58
Jim Goltz
None of these work verbatim on Solaris 10.  In Solaris Land, "egrep" has no "o", "a", or "m" options and "head" has no "c" option.  Also, stock "egrep" doesn't support "{}".

Slight correction: the "openssl" trick does work.
Posted 2009-11-12 10:50:34
maat
strings -n8 /dev/urandom|head -1

Works on Solaris 8 too.
Posted 2009-11-28 12:27:26
Rai
Use 'mkpasswd' Linux command with the required options.

'mkpasswd -l 8' should suffice here.
You can make it still complex using something like : mkpasswd -l 15 -d 3 -C 5 -s 3 -2
Posted 2010-02-10 15:32:06
i have test in solaris 8 working :d
Posted 2011-03-24 08:57:17

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit