Jump to content


0
[Tutorial]

Linux Random Password Generator Command



1 reply to this topic

#1 roy12499

roy12499

    Linux TE

  • Technical Expert
  • PipPip
  • 19 posts
  • 26 thanks

Posted 21 August 2011 - 04:10 PM

Linux Random Password Generator Command

Generate random passwords on the Linux command line using the bash shell?

You can use the following shell function to generate random password. Edit ~/.bashrc file, enter:
$ vi $HOME/.bashrc
Append the following code:


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


Save and close the file. Source ~/.bashrc again, enter:
$ source ~/.bashrc
To generate random password, enter:
$ genpasswd
To generate 8 character long random password, enter:
$ genpasswd 8

Edited by roy12499, 21 August 2011 - 04:17 PM.


Thanked by 3 Members:
itech , GhostProtocol , harry817

#2 spigy11

spigy11

    Member

  • Members
  • PipPip
  • 14 posts
  • 8 thanks

Posted 25 December 2011 - 07:39 PM

nice one never used that stuff with .bashrc and local ;)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

Organization

Community

Downloads

Test Providers

Site Info


Go to top