Generate Random String with CLI
August 03, 2026TIL a few one-liners to generate random strings.
date +%s | sha512sum | base64 | head -c 24 ; echo
The string is pseudo random and seeded by the current UNIX timestamp. The
command should with most Linux distros and MacOS. If running on Linux a more
random command uses /dev/urandom and tr.
tr -dc A-Za-z0-9 </dev/urandom | head -c 24; echo
If you need a passphrase you can use the dictionary file to select n random words.