LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   viewing a locked account (https://www.linuxquestions.org/questions/linux-general-1/viewing-a-locked-account-568332/)

tataiermail 07-11-2007 02:20 AM

viewing a locked account
 
hi all,

i have locked an account with usermod -L usrname.
i know i can unlock with -U switch.
but, where can i check that the account is locked or how can i check which r the accounts that r locked in the system?

thanks in advance,

suman:scratch:

reddazz 07-11-2007 03:00 AM

If you look in /etc/passwd, locked accounts will have an exclamation mark (!) in the encrypted password section.

b0uncer 07-11-2007 03:07 AM

Exclamation mark is generally used, but as far as I understand, an account can be "locked" by adding a character into the encrypted password field in /etc/shadow (most systems don't have a password in /etc/passwd because it needs to be readable by the users, the encrypted password is stored in /etc/shadow instead) that "doesn't fit" there. It means that only certain characters can be used in the encrypted password, and if a character is found from the field that is not supposed to be there, the password is unreadable by the program and thus the account is locked.

tataiermail 07-11-2007 03:17 AM

hi,
thanks a lot to both of you guys.
thanks reddazz, for giving me the quick reply.
but as b0uncer said now a days the password stays in /etc/shadow.
thanks b0uncer, for your detailed explanation.
yes, i have found that my testuser is havin a ! mark in beginning of the password field in shadow.
so, this way i can check whether the login problem is due to disabled account.

thanks a lot guys,

suman

jschiwal 07-11-2007 03:20 AM

If you use shadow passwords, locking an account prepends an exclamation point to the encrypted password field.
Using usermod -U username removes the asterisk.

So "sudo sed -n '/^[[:alpha:]]*:\!/p' /etc/shadow" will list the locked accounts, which will include locked system accounts.

reddazz 07-11-2007 03:21 AM

Actually, its my error there. I meant to say /etc/shadow and not /etc/passwd. Cheers for the correction.


All times are GMT -5. The time now is 12:53 PM.