Linux Command details chpasswd batch change user passwords
Command: chpasswd
Batch change user passwords
Working principle:
Read the user name and password from the standard input of the system, and use this information to update the existing user password on the system.
Syntax:
1: # echo Username: Password | chpasswd
2: # chpasswd <doiido.txt
Parameters:
-E: If the-e option is used, the password can only be passed in encrypted mode.
If the-e option is not used, the password will be passed in plaintext
Notes
1: The user name must be an existing user on the system.
2: normal users do not have permission to use this command
3: If the input file is transmitted in non-encrypted mode, encrypt the file properly.
4: The command file cannot be empty.
Instance
1. directly change the doiido user password to helloboy.
# Echo doiido: helloboy | chpasswd
2XX use the username and password in doiido.txt to modify the passwords of corresponding users in batches
2.1: first set up the instruction file doiido.txt (Format: [username: passwd])
# Vi doiido.txt
Doiido1: helloboy
Doiido2: hellogirl
2.2: transfer the content of doiido.txt to the chpasswd command to modify the password of the user.
# Chpasswd <doiido.txt
3. Let common users use chpasswd
By default, normal users do not have the chpasswd permission, but you can modify it by modifying the command file permission.
# Chmod 4755/usr/sbin/chpasswd
In this way, common users can use chpasswd to change their passwords.