Generate random password from command line

openssl rand -base64 32
or
LC_ALL=C tr -dc A-Za-z0-9 < /dev/urandom | head -c32; echo ''
Where 32
is length of the generated password.
I recommend the latter because the former is a based64 encoded result of a binary array, which has pre-defined pattern. This reduces the generated password space and produces weaker password than you expect in the giving size.
The latter command explanation
LC_ALL=C
: in some locale,A-Z
,a-z
contain some multiple byte character which are not supported bytr
command. Thus, error message is printed.-dc
flag intr
command:-d
means delete character in a given set.-c
means complement.