You can use the following shell function to generate random password.
Edit ~/.bashrc file, enter:
genpasswd() { local l=$1 [ "$l" == "" ] && l=16 tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs }
Save and close the file. Source ~/.bashrc again, enter:
$ source ~/.bashrc
To generate random password, enter:
$ genpasswd
To generate 8 character long random password, enter:
$ genpasswd 8