How to generate a new password on Linux

Linux

68 Words

2026-10-03 15:45 +0200


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