Generate random password in linux terminal

Password are valuable one. It’s a most used one in our daily life. So Password must be complicated and more tough to guess. Now let’s see How to generate random password in Linux terminal..

Generate random password in Linux terminal

Open your terminal:

And enter this command :

gedit $HOME/.bashrc

And Press Enter.

generate random password in linux terminal

 

Now Copy the below code and paste in the end of the bashrc file in which you have opened.

genpasswd() {
    local l=$1
           [ "$l" == "" ] && l=16
          tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}

Save and close the file.

generate random password in linux terminal

 

Basic Linux Command you should know

Click Here to Read

Now enter this command:

source ~/.bashrc
To generate random password, enter this command:

genpasswd

generate random password in linux terminal

To generate 8 character long random password, enter this command :

genpasswd 8

generate random password in Linux terminal

Was this article helpful?

Thanks

Thanks for your Feeback. It will helps us to improve our Article quality




32 Shares
+13
Tweet
Share29
Stumble