How to effectively disable a Linux user account?
Posted on In QANot yet to totally delete the Linux user account, but how to effectively disable a Linux user account?
That is, disable a user account while keep all its files/configurations. Later, if it is needed, so that I can enable it again.
To effectively disable a Linux user account so that it can’t login using its password or keys, you can use the usermod
tool:
Lock a Linux user zma2
:
# usermod -e 0000-00-00 -L zma2
Unlock the user locked by the above one:
# usermod -e "" -U zma2
The -L
/-U
options lock/unlock the user’s password and -e
set/clear the expiration dates so that the user can/cannot login using other ways than the password.