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.

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.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *