From time to time, we will need to disable users. This may be prior to the permanent deletion of the user account or just as a precautionary step.
As root, you can easily disable a user account by
# usermod –L <username>
Or you can just add an ! in front of the 2nd field (the encrypted password) in the /etc/shadow entry of the user.
To re-enable the user, you can
# usermod –U <username>
This will unlock the user, or simply put, remove the ! in front the password field of /etc/shadow.
If you would like to permanently delete a user, you should use
userdel –r <username>
to also remove their home directories. Note that in a typical administration, you would usually keep the home directory in case of the need for their data.



No comments yet.