Lock tempstaff's password hash without deleting the account or home directory.
Which command is appropriate?
usermod -L locks the password hash. It is different from disabling every possible authentication method or deleting the account.
Detailed explanation
usermod -U tempstaffIncorrect. -U unlocks the password.
Incorrect. -U unlocks the password.
usermod -aG locked tempstaffIncorrect. -aG adds a supplementary group.
Incorrect. -aG adds a supplementary group.
usermod -e '' tempstaffIncorrect. -e sets an account expiration date.
Incorrect. -e sets an account expiration date.
usermod -L tempstaffCorrect. -L applies a password lock marker.
Correct. -L applies a password lock marker.
Try it yourself
An example you can run in a temporary verification environment.
usermod --help 2>&1 | grep -E -- '-L|--lock' | head -n 1Expected result
-Lまたは--lockの説明行Key points
- -L locks
- -U unlocks
- No account deletion
Notes
- Environment: shadow-utils usermod help / account変更なし
- 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.