Linux chpasswd Command - Change Passwords in Bulk Mode

Creating users and managing passwords is one of the primary responsibilities of a system administrator. A good policy requires modification of passwords on regular intervals. But changing the passwords for a number of users with passwd command becomes difficult. In this article we provide a method to change the passwords in batch mode.

1. The chpasswd command:

The command chpasswd is used to modify the passwords in batch mode. Only root user can execute this command. It takes the passwords in the following format:


This syntax and usage of the command will be explained shortly. For this article, we consider following 5 users for which passwords will be modified:

1) linoxide
2) bobby
3) kyle
4) steve
5) joy

We provide here two methods in which chpasswd command can be used to modify the passwords in batch mode:

1.1 Method1: (STDIN)

In this method, just issue the command chpasswd and then it will prompt for the user passwords. The passwords will be given in the format shown above.

Providing passwords via STDIN

After you have entered all the users and passwords, you need to hit ctrl+d to tell the chpasswd command that this is end of input. You will get back your prompt after hitting ctrl+d and the passwords will be changed.

Pressing ctrl+d to submit

1.2 Method2: (Input from file)

You can alternatively maintain a file that contains all the users and the passwords. We can then redirect the input from this file.

Let us go ahead and create a file with cat command (You can use other methods to create the file as well like vi or emacs editor):

Saving passwords in file

Now all we need to do is issue the command chpasswd with input redirected from the file:

Providing input via file

2. Command options:

2.1 Providing encrypted passwords:

There are various useful options to this command. You can provide the passwords already encrypted with -e or --encrypted option.

Providing encrypted passwords instead of plaintext

2.2 MD5 passwords:

The -m or --md5 option will encrypt the password using md5 algorithm.

Passwords will be encrypted with md5 algo

2.3 Other encryption methods:

The encryption algorithm to be used for passwords can be provided with -c or --crypt-method option. In the example, we use SHA512 as our encryption algorithm:

Provide custom encryption method

2.4 Command help:

As with most commands, the -h or --help will print out the command usage for chpasswd command.

Help with command chpasswd

About Raghu

Raghu is working as Linux Server Administrator in Acknown Technologies Pvt. Ltd. He has been using Linux from last 5 years. He completed his RHCE certification in 2009. He likes to read about Linux and other Open Source Technologies and write articles on these.

Author Archive Page

Have anything to say?

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

All comments are subject to moderation.


  1. Hi,

    But, is there a command to get the encrypted password?
    In example 2.1 of this page, you provided an already encrypted password, but how you got it?


  2. Hi Filippo,

    There are a few commands that allow you to create encrypted passwords:

    You can use the command "grub-md5-crypt" generate encrypted passwords. But this command may not be available on Debian based OS such Ubuntu or Linux Mint. You can use another command that will be available on most *nix systems:

    openssl passwd -1 -stdin

    Hope that helps.
    Good Luck changing passwords. :)