Problem
Simple and easy method for generating random passwords from the command line.
Solution
Use the command below:
LC_ALL=C </dev/urandom tr -cd '[:alnum:]' | head -c 32
Explanation
This command generates a random string, remove non-alphanumeric characters and print the first 32 characters.
Adjust the length of the password by changing the number after -c in head -c 32.
Add symbols by replacing the character class with [:graph:] as in tr -cd '[:graph:]'.
Top comments (0)