This post will show you How to Lock and Unlock User account in Linux Easily.
If you are interested in learning, Request you to go through the below recommended tutorial.
DevOps Full Course Tutorial for Beginners - DevOps Free Training Online
Docker Full Course Tutorial for Beginners - Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners - Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners - Ansible Free Training Online
Openstack Full Course Tutorial for Beginners - Openstack Free Training Online
How to Lock and Unlock User account in Linux Easily
In this post, we will show you 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 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:::
Hope this post helped you to know How to Lock and Unlock User account in Linux Easily.
Related Content on Linux might be useful to you to improve your Linux Skills.
How to Configure IP Address on Ubuntu using Netplan
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
How to Access Linux Server from Windows Remotely
Configure SSH Passwordless Login Authentication (SSH-keygen)
How to Create LVM Partition in Linux – LVM Tutorial
Install & Configure Samba Server on Linux (RHEL7 / CentOS7)
Keep practicing and have fun. Leave your comments if any.
Support Us: Share with your friends and groups.Stay connected with us on social networking sites, Thank you.
1 تعليقات
[…] Click to see full answer […]
ردحذف