Q. How can I disable or lock a password for a User in Linux?
Some times it’s required to lock user not to login to the machine. This can be done by using passwd command. this command should be executed by root or super user. Execute below command lock a user.
passwd -l username
passwd -l surendra.
The above command will lock the user surendra prominently so that he can not login to the machine.
Once the password is locked or disabled !(negation sybol) will be added to password field in /etc/shadow file for that user.
Before password lock implemented, the entry for surendra as below.
After setting password lock:
If you try to login, you will get “Login incorrect“, This error is because ! in the password field of /etc/shadow file for user surendra.
Please follow our next post on unlocking the password.
Latest posts by Surendra Anne (see all)
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018
- wget download a file to a directory in Linux/Unix - June 4, 2018
- GIT: How to compare two GIT branches? - June 3, 2018
- Online training on Linux Bash shell scripting - February 8, 2018