Posted: . At: 1:53 PM. This was 8 years ago. Post ID: 8526
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to generate a random password using the command line.


The shuf command for Linux allows a command-line user to select a given number of random words from a wordlist.

[jason@localhost ~]$ shuf -n 8 /usr/share/dict/words
amphivasal
thoracically
U.
bluet
Dabih
thioamid
taxiing
convictism

This can be used to generate a word based password using piping. The example below shows how to generate a random password using the command line.

[jason@localhost ~]$ shuf -n 4 /usr/share/dict/words | paste -s -d ''
denaturizingdevastercomediettasSyryenian

This is another example, this generates a random password string that may be used for any login.

[jason@localhost ~]$ shuf -n 4 /usr/share/dict/words | awk '{print toupper(substr($0,1,1)) substr($0,2)}' | cut -d\' -f1 | tr -d '\n' ; echo
MoulviRagshagMacroglobulinemicColor-fading

Yet another example, generate an unbreakable password.

[jason@localhost ~]$ tr -dc "[:print:]" < /dev/urandom | head -c 128 ; echo
C+4r^ai05+^Z]ZtdC3&E~d&15BesG.}{EVI[+Oqb0e,kA8:RB!\7`h]rn=$Mz|:A7/ODh1^YOL3NE|KLWD/*oTJ}!&q2b?SB^?<B}}u5{r1.NmK~KL&hpU';mwr6D6lH

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.