top of page
  • Writer's pictureMahammad Rafi

Copy of How to check the lock status of any user account in Linux

1: Password Locked

In this case we are going to lock account password.


To lock the password.
 [root@net7 ~]# passwd -l aman
Locking password for user aman.
passwd: Success
[root@net7 ~]#

To review the status of user in /etc/shadow..!


[root@net7 ~]# grep aman /etc/shadow
aman:!!$6$ZpRT5ks9$Z22auP5UECfuzd3OgsCZTqvtmwpXyFKcgJyQbJFXouDb5E5qk97DU3F4IWMilWeG45nwrGHTO45kZ7z3vsFJG.:17760:0:99999:7:::
[root@net7 ~]#

Note: As you can see above two exclamation mark (!!) before the encrypted password which means that the password has been locked.


 To unlock the password
  [root@net7 ~]# passwd -u aman
Unlocking password for user aman.
passwd: Success
[root@net7 ~]#


2: Account is Locked

In this case the user account might have been locked by the administrator To lock an account.


 # usermod -L aman
 Review your /etc/shadow file for the changes
 # grep aman /etc/shadow
 aman:!$6$ciJaoDR9$Qpt9sctRLjbZ4/Agxy9UOvu/XQqNrFo9rpgfZ/xrF/8JphkEvF29ITpef0SVLdJcrpv8Q/.6mRAHee4tZT0r11:16299:0:99999:7:::

As you see an extra single exclamation mark(!) appeared in the password section before the encrypted password starts which signifies that the user account is locked

To unlock a user account.


 # usermod -U aman

Case 3: Password never set

This can also be the scenario where the administrator has not assigned any password due to which the user is not able to login. So to verify this again you need to check your /etc/shadow file.


 # grep aman /etc/shadow
 aman:!!:16299:0:99999:7::: 

As you see two exclamation mark(!!) is there but no encrypted password which means a password is not set. If the password was set without lock your /etc/shadow would look like something below.


# grep aman /etc/shadow
 aman:$6$ciJaoDR9$Qpt9sctRLjbZ4/Agxy9UOvu/XQqNrFo9rpgfZ/xrF/8JphkEvF29ITpef0SVLdJcrpv8Q/.6mRAHee4tZT0r11:16299:0:99999:7:::

Check the lock status of any Linux Account

Now one single command to see the lock status of the user.


 # passwd -S aman
 user1 LK 2014-08-17 0 99999 7 -1 (Password locked.) 

If the user account is unlocked you will output like below..!

# passwd -S aman
 user1 PS 2014-08-17 0 99999 7 -1 (Password set, SHA512 crypt.) 



7 views0 comments
bottom of page