SysTutorials Forums QA How to generate a password in Shell on Linux?

Viewing 1 reply thread

    Admins usually need to generate some passwords for others, such as when creating a new user in a Linux system. How to generate a password in Shell on Linux?

    Several possible and short methods. Here, we generate a password of length 8.

    Using pwgen:

    $ pwgen 8 1
    dao3PaW9
    

    Password based on base64 (note that the encoding of a 6 char string will be 8 chars in base64) with random numbers generated from various ways.

    Using gpg:

    $ gpg --gen-random -armor 1 6
    eXDvMVq2
    

    Using openssl:

    $ openssl rand -base64 6
    1E8oiu5G
    

    Using Linux' /dev/urandom:

    $  head -c 6 /dev/urandom | base64
    Ilna5Pj8
    

    There are possibly more.

    • This reply was modified 5 months, 2 weeks ago by Admins.
    • This reply was modified 5 months, 2 weeks ago by Admins.
    • This reply was modified 5 months, 2 weeks ago by Admins.
    • This reply was modified 5 months, 2 weeks ago by Admins.
Viewing 1 reply thread

The forum ‘QA’ is closed to new topics and replies.

Please share if you like this post: