Thursday, April 30, 2009

Disable a User Account in Linux

Technique 1 : Using /etc/shadow file

Linux systems use /etc/shadow to store the encrypted user passwords.

Active user account will have one line in /etc/shadow 

username:$2$eF7dafdsf$4kfdsm$3Fkm6nl.:13852:0:99999:7:::

Here second field is the encrypted password.


If we replace the password with “*” or “!” this will make the account unusable, and it means that no login is permitted for that user.


username:*:13852:0:99999:7:::


But disadvantage of this technique is password will be loss and we have to generate a new password for this user.


Technique 2 : Using passwd -l


It will lock the user account. After type passwd -l it will give you "password changed" message. This command will do the changes in the /etc/shadow file and add the "!" in the second field of that user.



username:!$2$eF7dafdsf$4kfdsm$3Fkm6nl.:13852:0:99999:7:::

if we want to unlock the user account then we can do that after removing "!" from /etc/shadow file. We can also do that mannual by using passwd -u command.




No comments:

sanjay's shared items

My Blog List