Creating user and managing user password is one of the basic tasks of the Linux system administrator. That's why the chpasswd command originated.
chpasswd command is used to change the password equivalent to "passwd" command. But chpasswd command allows changing passwords of multiple users easily.
In this context, we shall look into how to use the chpasswd command in Linux.
What is the syntax of chpasswd command ?
chpasswd command reads a number of username and password which are separated by colon using standard input or file, and then encrypt as per the options:
$ sudo chpasswd
You can Press Enter to go to the next user. Once done, press Ctrl+d to exit and the new password will be saved.
Or you can create a password file with the cat command:
$ cat > file.txt
Press Ctrl+ D to exit.
Then send this file to chpasswd command:
$ sudo chpasswd < pass.txt
chpasswd command Options
- -c, –crypt-method Method_Name : This command option is used for the crypt method. The method can be DES, MD5, SHA256, SHA512 or NONE.
- -e, –encrypted : It is used to supply the encrypted passwords.
- -h, –help : Used to display the command options and messages.
- -m, –md5 : It is used to encrypt the clear text password using the MD5 algorithm.
- -s, –sha-no_of_rounds : Here you can give the number of rounds for the SHA crypt algorithm.