Generate a random password


Alphanumeric:

head -c 250 /dev/urandom | LC_CTYPE=C tr -dc a-zA-Z0-9 | fold -w 32 | head -n 1

All characters:

head -c 500 /dev/urandom | LC_CTYPE=C tr -dc '[email protected]#$%^&*_-' | fold -w 32 | head -n 1

To output without a newline, get rid of the fold and use head -c:

head -c 500 /dev/urandom | LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 32

You can also use /dev/random, which might block but is theoretically more secure.

Tags:  bash

Share: