Oct 3, 2026
How to generate a new password on Linux
The idea is to use the urandom special linux file in order to generate a password. We will read the /dev/urandom flow and select the 20 last characters that are numbers or letters.
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1
If you want to include special characters:
cat /dev/urandom | tr -dc 'a-zA-Z0-9!@#$%^&*()_+-=' | fold -w 20 | head -n 1