I need to get the exact time and date at which a user account was locked or unlocked in Linux.
passwd -S command can give the status of an account i.e., if its locked or unlocked.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
I don't thing it is possible. Locking the account work simply by altering the user password hash in /etc/shadow to unusable string - the time of the event is not stored anywhere.
-l, --lock This option is used to lock the password of specified account and it is available to root only. The locking is performed by rendering the encrypted password into an invalid string (by prefixing the encrypted string with an !). Note that the account is not fully locked - the user can still log in by other means of authenti‐cation such as the ssh public key authentication. Use chage -E 0 user command instead for full account locking.
My suggestion is to track the times of locking and unlocking some other way (e.g. custom shell script). It pretty much depends on how do you actualy use the locking.