Generate Random String with CLI
August 03, 2026TIL a few one-liners for generating 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 work with most Linux distros and MacOS. If running on Linux a
more random command to try 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.