Linux/centosshell script non-interactive Password Change
Today, when I wrote a shell script, I found that the user's password needs to be set and the password is set to interactive. This is obviously not good in the script, So I went online to search for information, two non-interactive password setting methods are found: 1. You can use chpasswd to change the password of a group of users by entering the 'user name: password, it is also a tool for changing passwords in batches. For details about the usage, see chpasswd. Here we only provide a brief description of the format: # echo Username: Password | chpasswd. For example, if you want to add a doiido account, the password is 123456, and the command is as follows # echo doiido: 123456 | chpasswd 2. passwd and -- stdin are used as the standard input by default, -- stdin indicates that any file can be used as the standard input. The two combinations can directly modify the password format: # echo 'Password' | passwd -- stdin user name or add a doiido account, the password is 1234. 56. The command is as follows # echo '000000' | passwd -- stdin doiido so that you can change the password in non-interactive mode. However, these two methods are not supported for some embedded linux systems, you can use export.