Sometimes it is very useful to be able to temporarily block an user account for maintenance purposes. The passwd utility provides a set of functionalities to do so.
To lock an account simply type:
passwd -l user_login_name
Now check the status of the account:
passwd -S user_login_name
and you’ll get something like this…
user_login_name L 12/09/2003 0 99999 7 -1
From the passwd man page:
The account status may be given with the -S option. The status information consists of 6 parts. The first part indicates if the user account is locked (L), has no password (NP), or has a usable password (P). The second part gives the date of the last password change. The next four parts are the minimum age, maximum age, warning period, and inactivity period for the password.
To unlock the user account…
passwd -u user_login_name
passwd -S user_login_name
And as a result…
user_login_name P 12/09/2003 0 99999 7 -1