How to effectively disable a Linux user account?

Not 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.

asked Feb 27 by anonymous

1 Answer

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.

answered Mar 19 by Eric Z Ma (41,910 points)
edited 1 day ago by Eric Z Ma
Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost