3 Ways To Generate Random Passwords From Unix Command Line

3 Ways To Generate Random Passwords From Unix Command Line

One of the best things about Unix is that you can use it for any imaginable task under the Sun. The only condition being you apply sufficient brains.

There are many ways, online tools, applications to generate strong, non-dictionary passwords. In this tutorial, we learn how to generate them with use of Unix command line. These are simple, easy to remember one line commands, which generate unique password each time you run them.

For sake of brevity, in this tutorial we will learn to generate passwords of length 6. You can replace '6' with any number of your choice.

Method 1
The first is the most easy and simplest to remember way by using the output of the date command and then compute the md5sum message.
date | md5sum | head -c6 ; echo;

Vishal Lambe's Blog

 
Method 2
This one uses openssl’s rand function. However, openssl may or may not be installed on your system.
openssl rand -base64 32 | head -c6 ; echo;
Vishal Lambe's Blog
Method 3
This method used the built-in /dev/urandom feature, and filters out only characters that you would normally use in a password. Then it outputs the top 6.
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6 ; echo;
Vishal Lambe's Blog