Skip to content
April 30, 2009 / sanjaydalal4u

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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.