Xin Xing analyzes some issues about user locking in Linux. Xin Xing analyzes linux locking
Sometimes we need to lock users. There are usually three common methods:
(1) individual users are prohibited from logging on.
For example, to disable the qian user, we only need to use passwd-l qian.
If we want to unlock the qian user, we only need to use passwd-u qian.
(2) modify the configuration file to disable user logon.
For example, if we want to disable the qian user logon, we can change the shell to/sbin/nologin in/etc/passwd.
For example, this line can be changed to qian: x: 501: 501:/home/qian:/sbin/nologin.
(3) Lock all users
For example, to lock all users, we only need to create a/etc/nologin file, so that all users except root cannot log on.
If we lock the user qian, we can still use the root user su to qian, because the root permission is so special, but other users, for example, if xin cannot su to qian, it always prompts: su: the password is incorrect.