Quickzi: Generate Random Passwords on the Linux Command Line

Here is a quick one line command to generate a random password from the Linux command line.

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

If you want a password length longer than 6, changing the -c6 to read -c8 will give you 8 random characters instead of 6.

6 thoughts on “Quickzi: Generate Random Passwords on the Linux Command Line

  1. Hi,

    I need to generate 10 random numbers using /dev/random.
    Is this possible ?
    Can you give me syntax for same.
    Also how can i execute this in PHP.

    Thanks in advance

  2. no_of_passwords=10
    password_lenght=16

    i=0
    while [[ $i -le $no_of_passwords ]]; do
    new_pass=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c$password_lenght)
    [[ -n "$new_pass" ]] &done

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>