How To Disable or Lock Linux User Account?
How can I disable some linux account? By disabling it I do not want to remove the account and related files. Just user related operations will be prevented. If an user authentication occures it will be not authenticated. We will use usermod command to lock user account.
Disable User Account
We will disable account with the following code.
$usermod -L -e 1 test
- usermod will change user account related attributes and information.
- -L will lock given account and put ! in the user passwords database before encrypted password.
- -e 1 will set expire date from 1/1/1970
We will check the status of this account from configuration file. Is the account disabled?
$cat /etc/shadow | grep test
There is an other way to check Configraution
$chage -l test
Last password change : Kas 07, 2016
Password expires : never
Password inactive : never
Account expires : Oca 02, 1970
Minimum number of days between password change :
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7