Working with Linux as system administrator, there likely will be times that need to lock the user. It can be useful when limiting access to a system temporary. This tutorial shows how to lock and unlock user in Linux.
passwd command for working with passwords of a users. This command also can be used to lock and unlock user. The
passwd command basically works with
To lock a user, use the option
-l with username as follows:
sudo passwd -l john
Status of a user can be checked with
sudo passwd -S john
john L 06/12/2022 0 99999 7 -1
The second field in the output means:
PS- user has a password (user is unlocked).
LK- user is locked.
To unlock a user, use the option
-u with username as follows:
sudo passwd -u john