HowTo: Linux Random Password Generator Command

The easiest way to generate a random password in Linux is to use the “openssl” command. The following command will generate a 12-character random password:

openssl rand -base64 12

This generates a random string of 12 characters that is base64-encoded, which gives you a set of characters that are safe to use in a password.

If you want to generate a random password with a different length or with a different character set, you can modify the command accordingly. For example, to generate a password with 20 characters, you can use the following command:

openssl rand -base64 20

To generate a password with only upper-case letters, numbers, and symbols, you can use the following command:

openssl rand -base64 12 | tr -dc 'A-Z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c 12

This command uses the “tr” command to remove any characters that are not upper-case letters, numbers, or symbols, and the “head” command to truncate the output to the desired length.

Leave a Comment