Question - How to lock a user account in Linux?
Answer -
Locking user account is done for the security purpose so that unauthorized users cannot log in. So, we have a few ways to lock the user account. Some of them are below.
- Lock or disable the password using passwd command.
- Expire the user account using usermod command or chage command.
- Changing the shell using nologin command ( /sbin/nologin ).