Generate random string from Linux command line


Command

Use the following command to generate a random 16 character string with lower and upper case letters and "special" characters.

</dev/urandom tr -dc '0123456789!@#$%^&*abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | head -c16; echo ""

Output

2kQjZ&iHSavVPj&U

If you prefer only eight alphanumeric characters, use:

</dev/urandom tr -dc '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' | head -c8; echo ""

TCxvA40s