Requirements Description :
Linux environment in the creation of users, involves the modification of the user's password, generally through the passwd command to modify, need to confirm multiple times, here consider a command directly to modify the password
There is no way to interact. This record.
Operation Process :
1. Use the echo command to combine the passwd command to achieve
Echo " mytest " passwd -- for user mytest. passwd: All authentication tokens updated successfully.
Note: The part marked in red is the password. passwd using the--stdin option means telling the passwd command to read the new password from the standard input. Reads the standard input from the previous pipe .
2. Verify that the password is successfully modified by toggling
su - mytest # switching from root to normal user does not require a password su - mytest # to switch users again , you need to enter a password ~]$ # password is correct, you can perform a normal switchover
Note: You can already successfully log in using a password that you previously set.
passwd's--stdin is explained as follows :
--stdin This option was used to indicate that passwd should read the new password from standard input, which can be a Pipe.
Document creation time: July 2, 2018 13:14:12
How does Linux modify a user's password through a script? Scripting Automation modifies user passwords?