Article Title: how to disable a user account in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
In Linux, use/etc/shadow to save the encrypted user password. The fastest way to disable an account is to modify the password stored in/etc/shadow, A valid Linux User usually has the following line in/etc/shadow:
User: $1 $ eFd7EIOg $ eeck6xgktwsugi2pgupk.: 13852: 0: 99999: 7 :::
Each field is separated by a colon. The second field is the user password information. If we change the second value to an asterisk * or an exclamation point! This account is disabled and users cannot use this account to log on to the system:
User: *: 13852: 0: 99999: 7 :::
Here I will introduce a simpler method:
Sudo passwd-l User Name
Disable this account. View/etc/shadow and you will find that a exclamation point is added before the password.
Re-enable this account using the following command:
Sudo passwd-u User Name