Creating user and managing user password is one of the basic tasks of the Linux system administrator. That’s why the chpasswd command was born.
chpasswd command is used to change the password equivalent to passwd command. But chpasswd command allows changing passwords of multiple users easily.
This article will show you how to use the chpasswd command in Linux as we go through below.
The syntax of chpasswd command
$ sudo chpasswd
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
- -e Use encrypted password
This tells chpasswd that your password is encrypted so chpasswd won’t re-encrypt it.
- -m , -md5 Use MD5 hash encryption
- -c Choose 1 encryption method
For example, I want to choose DES as the encryption method for my password:
$ sudo chpasswd -c DES
- -h, -help Ask for help information from the command
You’ve already gone through the details of how to use the chpasswd command in Linux.
Thanks for reading.