Skip to content

10 Ways to Generate Secure Passwords on Linux

It is more important than ever to use strong passwords for your online accounts. Without a strong password, it is easy for others to crack it. It’s great if you can come up with a good password yourself, but if you run out of ideas or feel like your password isn’t strong enough, you can have your computer impersonate it for you.

Here are 10 ways to generate brand new secure passwords you can trust on Linux.

1. APG

The Automatic Password Generator, or APG, is installed on all Ubuntu systems. This is an easy to use utility that can give you different passwords based on random keyboard input. For example, you can run this command from the Ubuntu Command Line Interface (CLI):


This will suggest six “pronounceable” passwords. They should be pronounceable to make them more memorable, although most of them are still random.

If you want completely random passwords, you can run:

apg -a 1

This command will give you passwords of eight to ten completely random characters. Of course, it’s also only after you’ve given it random keyboard input.

001 - 10 Ways to Generate Secure Passwords on Linux001 - 10 Ways to Generate Secure Passwords on Linux

2. pwgen

pwgen is another utility that can be quickly installed with the command:

sudo apt-get install pwgen

If you have a password generator tool on your system, run this command to generate passwords:


The command will fill your terminal with a lot of passwords, so you just have to pick one at random (preferably not the first or the last).

This is done in case someone is nearby or looks over your shoulder – that way they won’t know which password you have chosen from the many displayed.

002 - 10 Ways to Generate Secure Passwords on Linux002 - 10 Ways to Generate Secure Passwords on Linux

You can also use different flags to set the password:

How to generate only one password

Use the -1 flag to generate a single password instead of an entire screen filled with them.

How to generate a password using a different algorithm

If you run the command with the -s flag, the password is generated using a different algorithm to make it even more secure.

How to generate a password with special characters

The -y flag adds special characters to the provided password.

How to generate a password without numbers

The -0 flag generates a password containing no numbers.

How to generate a password without complex characters

The -B flag disables hard-to-read characters such as 1 I l or 0 O

How to generate a password without vowels

The -v flag does not allow vowels. This is mainly used if the website does not allow offensive passwords.

3. makepasswd

makepasswd is another utility that makes creating passwords easier. You can install it with this command:

sudo apt-get install makepasswd

From there, you can generate multiple passwords with this command:

makepasswd -count X -minchars Y

Replace “X” with the desired number of passwords and “Y” with the minimum length of each password. It is also flexible enough for other users.

For example, the following command will give you a randomized numeric password consisting of only four digits, i.e. PIN (Personal Identification Number):

makepassword -string 1234567890 -chars 4

4. passwordmaker-cli

If remembering your passwords is the hardest part of using secure logins, then a password maker will be your new best friend. You can install it with this command:

sudo apt-get install passwordmaker-cli

To use this command line utility, run:

passwordmaker --url

Replace “” with another website of your choice. It will then ask you for a master password before giving you a secure one.

The advantage of this tool is that you can use the same master password and get different passwords for different sites. If you have forgotten the password for a specific site, you can run the utility again with the same site and master password and you will get the same secure password. It will most likely remind you of password managers.

5. Manually with well thought out commands

You can also try using some well-thought-out commands to create your own passwords without relying on special utilities to generate them. For example, you can use the following command to create a password, and it will always be unique because it is based on the current date, including seconds:

date +%s | sha256sum | base64 | head -c 32 ; echo

Another example that is easier to remember (i.e. the command, not the password it generates)::

date | md5sum

6. OpenSSL

OpenSSL also helps generate passwords. Using the rand function, you can have many random secure passwords on Linux. All you have to do is specify the length of the password you want to generate.

Many Linux distributions come with OpenSSL preinstalled; however, they may not have the rand function. To do this, you need to install it on Ubuntu using the APT command:

sudo apt install rand

Once the feature is installed, you can generate a password with the following command:

openssl rand -base64 14

“14” is the password length, but you can use any password length.

7. GPG utility

Another widely used password generation method is GPG. It is also a command line tool available on Linux, Windows and Android. For example, to create a 16 digit password, you can run the following command:


8. Perl Script

You can also use a Perl script to generate any number of passwords on a Linux system. To install perl on Ubuntu, use the apt-get command:

sudo apt-get install perl

Once installed, create a perl file to which you will add a script to generate passwords. Create a .pl script file using the nano editor:


Add the following content to the .pl file:


my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);

my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..8;

print "$randpasswordn"

To save the file, press Ctrl + X then Y and press Enter.

Now run the script with the perl utility to generate a password:


9. Revelation User Interface

If you are not comfortable using the Linux command line, you can use a user-friendly graphical user interface (GUI) application to generate passwords. One such tool is Revelation. To install Revelation on Ubuntu, type the following command:

sudo apt-get install revelation

Once launched, choose View > Password Generator to open the password generator window. Here you will specify the length of the password you want to create. You can also check the box at the bottom if you want punctuation in the password to make it more complex.

To generate a password, click the Generate button.

10. UI Keepassx

Another GUI app that you can use to create passwords in Keepass. It is a password management tool that is also easy to install and use on Linux. To install Keepass on Ubuntu run:

sudo apt-get install keepassx

Now run it and click Database > New Database. Here you will provide a master key and then click OK. Then go to Groups > Add New Group. Give the group a name and click OK. Then click Posts > Add New Post.

To generate a password, click the Gen button. located on the right. You can also specify the length of the password and the characters you want to use.

What do you use for passwords?

There are many ways to generate secure passwords on Linux, so there is no excuse not to.

It is important that your passwords are kept private and secure. No matter how many tools you use to create long, complex passwords, it’s all about keeping them safe in the end. Anyone can force you to reveal passwords. Make it a rule not to trust anyone with your login details, no matter what.

2562500cookie-check10 Ways to Generate Secure Passwords on Linuxno

Publication author

offline 1 day


AEdFTp7yONh1pyC14k08EHSejujrCNwEKzHR2o 3E vHww=s96 c?sz=50 - 10 Ways to Generate Secure Passwords on Linux

Comments: 6Publications: 1194Registration: 29-04-2020


#Ways #Generate #Secure #Passwords #Linux

❤ XOXO ❤

Leave a Reply

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