To generate a random password on a Linux system, you can use the pwgen
command. This utility can generate passwords that are secure and random, and it has a variety of options to customize the output.
Here's an example of how you can use pwgen
to generate a random password:
pwgen -sy 20 1
This command will generate a single, 20-character password that contains symbols and digits, but no upper-case letters. The -s
flag tells pwgen
to include symbols in the password, and the -y
flag tells it to include digits. The 20
parameter specifies the length of the password, and the 1
parameter tells pwgen
to generate a single password.
You can customize the output of pwgen
in a number of ways. For example, to generate a password that contains upper-case letters as well as symbols and digits, you can use the -B
flag:
pwgen -Bsy 20 1
To generate a longer password, you can increase the length parameter. For example, to generate a 30-character password, you can use:
pwgen -Bsy 30 1
You can also generate multiple passwords at once by increasing the final parameter. For example, to generate 5 random passwords, you can use:
pwgen -Bsy 20 5