How to Lock User Account in Linux with passwd command
How do we disable a Linux user temporarily without deleting the user account?
We can easily lock user account using the passwd command with -l option.
passwd -l username
User will get "Login incorrect" message at user login.
To reactivate the user account, unlock the user with -u option:
passwd -u username
Example
Following command will lock the user 'admin':
passwd -l admin
Unlock the admin user with -u option:
passwd -l admin
passwd command adds a '!' at the beginning of the password
When we disable a user account with passwd command, it adds an Exclamation mark (!) at the beginning of the user password.
When unlocks the account, it will remove the Exclamation mark from the hash password.