How to Lock and Unlock User account in Linux

how to lock user in linux, linux lock user account, lock user account linux, how to unlock user in linux, linux unlock user account, unlock user account linux

In this post, we explain you about how to lock and unlock user account in Linux. Before locking or unlocking the users, we should know how to check the status of the users.

How to lock the users in Linux?

Option 1: Use the command "passwd -l username".
[root@localhost ~]# passwd -l username
Locking password for user username.
passwd: Success
Option 2: Use the command "usermod -l username".
[root@localhost ~]# usermod -l username
How to unlock users in Linux?

Option 1: Use the command "passwd -u username".
[root@localhost ~]# passwd -u username
Unlocking password for user username.
passwd: Success
Option 2: Use the command "usermod -U username".
[root@localhost ~]# usermod -U username
How to check the status of the users is locked or not?

Find the user in the /etc/shadow file for exclamation(!) sign after the username.

If the user is locked using "passwd -l username" command, we could see a single exclamation as below.
[root@localhost ~]# grep username /etc/shadow
username:!$6$pmQO0ZPH$CodOZ5xfPHmgdR8czIFFL07wPipBpczjeXz5wapGUNj1NLsnrlCEzxOyk6/oL.WIFSoCCppwbCi7bQ//HJAn8.:16052:0:99999:7:::
If the user is locked using the "usermod -l username", then we could see double exclamation as below.
root@localhost ~]# grep username /etc/shadow
username:!$6$pmQO0ZPH$CodOZ5xfPHmgdR8czIFFL07wPipBpczjeXz5wapGUNj1NLsnrlCEzxOyk6/oL.WIFSoCCppwbCi7bQ//HJAn8.:16052:0:99999:7:::
How to Lock and Unlock User account in Linux, how to lock user in linux, linux lock user account, lock user linux, lock user account linux, how to unlock user in linux, linux unlock user account, unlock user linux, unlock user account linux, how to unlock user account in linux, how to check user account is unlocked, how to lock user account in linux, how to check user account is locked
August 07, 2016

Post a Comment

[disqus][facebook][blogger]

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget