Different Ways To Generate A Random Password From The Command Line In Linux

Linux has always been great in providing security on your operating system. With this, it can allow you to use hundreds of commands to control over your used password thus making your machine or services more secure.

All of these commands were tried and tested on several Linux-operated computers and all of them worked like charm.

Generate Random Password Linux

Keep in mind that as you use these commands, you can always change the length of allowed passwords. All you have to do is to look for the first “x’ of the command. This is actually the most crucial part of this method.

However, if you are using LastPass (Download link), then you are in good hands. It can help you to remember your password without the needs of memorizing them.

Ways To Generate A Random Password From The Command Line In Linux

date +%s | sha256sum | base64 | head -c 32 ; echo

1. This command allows you to use SHA to remember the date. Then, goes along with base64 and sticks with the 32 characters limit.

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;

2. This method on the other hand will allow you to be guided on the characters you are only allowed to use on your system.

openssl rand -base64 32

3. This method on the other hand is limited to openssl. This will never be installed on your system but still a good one.

tr -cd ‘[:alnum:]’ < /dev/urandom | fold -w30 | head -n1

4. A method which works very similar with other urandoms. A good choice so far.

strings /dev/urandom | grep -o ‘:alnum:’ | head -n 30 | tr -d ‘n’; echo

5. Another urandom command which can limit the strings used as command.

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6

6. A simpler version of the urandom command. A good alternative.

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

7. This is a more complicated command but can work great than the other simpler ones.

8. A cool command which allows you to type in the password with left-hand password using your just one hand.

randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;}

9. If you are already used to creating commands for your password, then having this command is perfect for you. This will help you to generate random password every now and then.

date | md5sum

10. But if it is your first time to do all these commands, why not settle with the simplest one. This command actually works on Windows, Linux or even Mac. This is a small command but a random password generator perfect for novice.

Not only these, there are plenty more ways available to generate a random password from the command line in Linux. What is your favorite way?

(Visited 97 times, 33 visits today)

Speak Your Mind

*