Terms of Use For FixedByVonnie

By proceeding to access fixedByVonnie.com, you expressly acknowledge, and agree to, all of the following:

fixedByVonnie.com is a personal website and blog owned by Security Plus Pro LLC, which is being presented for informational purposes only. The views on this website are solely those of the website owner (and not those of any employer or of any professional associations affiliated with the website owner).  Any views expressed in this website and any information presented on this website, or in any of its blog entries, should not be relied on for any purpose whatsoever other than as the personal opinions of the website owner.  The website owner expressly disclaims any and all liability for any information presented on this site.  The owner of this website and its blog posts shall not be held liable, and shall be held harmless, for any errors or omissions in any information or representations contained in this website, or in any of its blog entries.  The website owner also expressly disclaims any liability for the current or future availability of any such information. The website owner makes no representations as to the accuracy or completeness of any information on this website or which may be found by following any link on this website. The website owner shall not be held liable for any losses, injuries, damages, claims, or causes of action, from the display or use of any information on this website or in any of its blog entries. If you use the information on this website, or on any of its blog entries, you do so solely at your own risk.

3 fast ways to generate a random password from the command line in Linux - fixedByVonnie

3 fast ways to generate a random password from the command line in Linux

First up, if you really want to generate random passwords, I say scrap the command line and use LastPass to generate a random password.  It lets you set the password length, case, symbols, minimum digit counts and a bunch of other things. It’s actually the fastest way to generate a random password other than by making love to your wife on your keyboard with notepad open and recording the gibberish that comes out.

Graphic but true.  Let’s get on with it lol.

I’m going to move quick here so catch me if you can.

1. Get a date

Need a rando password like right now?  Why the hurry?

Okay, that’s none of my business.

The bottom line is if you need a quick one just type:

date | md5sum

Use date | md5sum to generate a random password

So what’s going on here?

We’re just running the data output of the date command into a 128 cryptographic md5 checksum function.  Despite the convoluted explanation, it’s not the most secure thing in the world.  The bottom line is that it exceeds most password length requirements and is relatively random since it’s based on the ever changing time input.

2 U so random!

the /dev/urandom application gives us a little more precision than the md5sum thingy we typed earlier.  Here’s the command :

sudo < /dev/urandom tr -dc _A-Z-a-z-0- | head -c12

Using urandom to generate a rando password

Yes, the output is a little confusing because the command is long and the output is poorly formatted.

In the above screenshot, the password is highlighted immediately to the left of the second line.

That last part of the command head -c12 specifies the character length – so if you wanted 15 characters instead of 12 you would change it to:

head -c15

3. Duplicate me baby

The dd command is usually used to copy and convert files.  Today we’re gonna make it do something it never dreamed of: generate random passwords.

Oh yeah! lol

dd if=/dev/urandom bs=1 count=16 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev

Using dd to generate random passwords

And now we have a 16 character super random password that would importune even the most resolute hackers.


That’s it.  In the blink of an eye we have three methods of generating random passwords in Linux.

If you have any other methods please share in the comments!


Connect with Vonnie on Twitter

Posted in Linux, Mac OS X 10.10 Yosemite, Mac OS X 10.8 Mountain Lion, Mac OS X 10.9 Mavericks Tagged with: ,