In this little guide, we will see how to generate passwords randomly via the command line. The commands given below will run on almost all Linux-based distributions, but for my part, I tested them only on Ubuntu and Debian.

1. The first command is the following:

openssl rand -base64 9

2. Here is another command:

egrep -ioam1 '[a-z0-9]{10}' /dev/urandom

3. This command also allows to generate passwords via the command line:

< /dev/urandom tr -dc A-Za-z0-9_ | head -c10 | xargs | cat

4. You can also use makepasswd to generate random passwords on Ubuntu/Debian. Before giving the command, let's first install makepasswd on both systems with these commands:


sudo apt-get install makepasswd


su -
apt-get install makepasswd

Then run this command to generate a password:

makepasswd --chars=10

Note: You can change the number of characters for the password you want to generate by modifying numbers displayed in red.

That's it!

Post a Comment