top of page

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

  • Writer: Mahammad Rafi
    Mahammad Rafi
  • Nov 23, 2020
  • 2 min read

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.) 



Commenti


adult-apple-device-business-340152.jpg

Linux .....because life is too short for reboots

I am an avid fan of Linux and open source enthusiast so I make a  decision to meet people through Technical Live Blogger. I have been enjoying Linux for the past six years. Back in 2013, I stumbled upon an article about the Ubuntu live CD. That moment changed my life. I know that statements like that belong to those exaggerators but it is actually true. Within 24 hours of reading the article, I had turned my own desktop in Ubuntu one – a platform where I have explored many Linux things ever since. If you just want to say hello, do say "Hello" at md.rafi1615@gmail.com or visit the virtualworld.

  • LinkedIn Social Icon
  • Twitter Social Icon
  • Instagram Social Icon
  • Facebook Social Icon

© 2023 by Extreme Blog. Proudly created by Mahammad Rafi

bottom of page