Monday, January 21, 2013

How To Lock/Unlock and Check The User In Linux.


## You can use this command to lock the User: shrii.

[root@localhost ~]# passwd -l shrii
Locking password for user shrii.
passwd: Success

##  This command shows you particular user status. If it is locked or unlock.

[root@localhost ~]# passwd -S shrii
shrii PS 2013-01-21 0 99999 7 -1 (Password set, MD5 crypt.)

## Using this command it will give you list.
[root@localhost ~]# cat /etc/passwd | cut -d : -f 1 | awk '{ system("passwd -S " $0) }' 

test PS 2012-12-27 0 99999 7 -1 (Password set, MD5 crypt.)
shrii PS 2013-01-21 0 99999 7 -1 (Password set, MD5 crypt.)
shrikant LK 2013-01-21 0 99999 7 -1 (Password locked.)
yo LK 2013-01-21 0 99999 7 -1 (Password locked.)


## Using the -u option you can unlock the user.
[root@localhost ~]# passwd -u shrii
Unlocking password for user shrii.
passwd: Success.

####### Another way to lock/unlock the user is "usermod".

## For Locking user.

usermod -L username

## for Unlocking the user.
usermod -U username