frederik's blog

Music (5) Projects (2) Snippets (8) Technology (5) Thoughts (8)


Generate “random” passwords from the command line


I type this into my terminal when I just need a quick “random” password.

$ date +%s | sha256sum | base64 | head -c 32 ; echo

This is the output:


Adjust the length by changing -c 32 to something else.

Passwords generated like this are not really random since they’re based on the date. For my purposes it’s perfect but the following might be better suited for you.

$ </dev/urandom tr -dc 'A-Za-z0-9@#$%&_+=' | head -c 32

The output looks similar to the example above but there are now special characters included:

$ RXd+zEtz5olv$uxzw=OV#zK6v&4q5LgH