How to lock and unlock user account in linux
In this post we will learn about how to lock and unlock user account in linux.With the help of two commands you can lock and unlock the user account in linux.We will also know, how to find the user account has lock and unlock status.
To Lock the user account in Linux,use the given below command syntax
We have two options to use any of the given below command to lock the user account in linux
By Using Passwd command
1
|
passwd -l username
|
OR
By using usermod command
1
|
usermod -L username
|
Example. to lock the user account called sharad in linux system
1
2
3
4
|
[root@localhost ~]# passwd -l sharad
Locking password for user sharad.
passwd: Success
[root@localhost ~]#
|
OR
1
2
|
[root@localhost ~]# usermod -L sharad
[root@localhost ~]#
|
To Unlock the user account in Linux,use the given below command syntax
By Using Passwd command
1
|
passwd -u username
|
OR
By using usermod command
1
|
usermod -U username
|
Example. to unlock the linux user account called sharad
1
2
3
4
|
[root@localhost ~]# passwd -u sharad
Unlocking password for user sharad.
passwd: Success
[root@localhost ~]#
|
OR
1
2
|
[root@localhost ~]# usermod -U sharad
[root@localhost ~]#
|
How to check the status of Lock and unlock user account in linux
It is good to explain to check the status of lock user account with example.Here the user account name is sharad . The status can be checked from /etc/shadow file
Note: The user account has password in this example
Example, after locking the user account by using passwd command. The double exclamation(!!) sign after username called sharad confirmed the account is locked.
Example, after locking the user account by using passwd command. The double exclamation(!!) sign after username called sharad confirmed the account is locked.
1
2
3
|
[root@localhost ~]# grep sharad /etc/shadow
sharad:!!$6$pmQO0ZPH$CodOZ5xfPHmgdR8czIFFL07wPipBpczjeXz5wapGUNj1NLsnrlCEzxOyk6/oL.WIFSoCCppwbCi7bQ//HJAn8.:16052:0:99999:7:::
[root@localhost ~]#
|
Example, after locking the user account by using usermod command. The single exclamation(!) sign after username called sharad ,confirmed the account is locked.
Note: if user passwd is not set and if we use usermod command to lock the account,it will show double exclamation sign
1
2
3
|
[root@localhost ~]# grep sharad /etc/shadow
sharad:!$6$pmQO0ZPH$CodOZ5xfPHmgdR8czIFFL07wPipBpczjeXz5wapGUNj1NLsnrlCEzxOyk6/oL.WIFSoCCppwbCi7bQ//HJAn8.:16052:0:99999:7:::
[root@localhost ~]#
|
No comments:
Post a Comment