passwd lock and unlock Explained¶
Introduction¶
This article explains a common passwd usage that administrators and learners often need to understand clearly.
What This Command Means¶
The command performs this specific task with passwd:
sudo passwd -l student
Breaking Down the Command¶
passwdis the command being run.- The options or arguments decide the behavior.
- The final value is the target, such as a file, process, service, package, host, URL, or directory.
Practical Examples¶
sudo passwd -l student
sudo passwd student
sudo passwd -S student
Example output:
student LK 2026-05-30 0 99999 7 -1 (Password locked.)
When to Use It¶
Use passwd to set passwords, force password changes, and lock or unlock password-based login. Pair it with chage when password aging policy matters.
Common Mistakes¶
- Assuming password lock blocks SSH key authentication.
- Unlocking an account without checking expiry or aging settings.
- Using weak temporary passwords on shared systems.
Safer Alternatives¶
Inspect before changing state when possible:
sudo passwd -S student
For wider changes, test on a small target before using the command broadly.
Related Guides¶
Summary¶
Understanding passwd lock and unlock is about knowing what each part does and checking the final state after running it.