Lock the password for user trainee so password authentication is disabled.
Do not delete the account or its home directory.
Which command is appropriate?
passwd -l USER locks the password hash. This is different from deleting the password or disabling every possible authentication method.
Detailed explanation
passwd -d traineeIncorrect. -d deletes the password and creates a passwordless state.
Incorrect. -d deletes the password and creates a passwordless state.
passwd -e traineeIncorrect. -e expires the password immediately.
Incorrect. -e expires the password immediately.
passwd -l traineeCorrect. It locks password authentication for trainee.
Correct. It locks password authentication for trainee.
passwd -u traineeIncorrect. -u unlocks a locked password.
Incorrect. -u unlocks a locked password.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '-l=lock password' '-u=unlock password' '-d=delete password' '-e=expire password'Expected result
-l=lock password
-u=unlock password
-d=delete password
-e=expire passwordKey points
- -l locks the password
- Account-wide disable is separate
- Distinguish -u, -d, and -e
Notes
- Environment: shadow-utils passwdのoption対応表
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.