nologin

Deny user login to the system

Supplementary instructions

nologin command can politely refuse the user to log in to the system and give information at the same time. If you try to log in as this type of user, add a record to the log, and then output the message "This account is currently not available" in the terminal, that's it. Generally, such an account is set up for the account that starts the service. It only allows the service to start, but cannot log in to the system.

grammar

nologin

Example

Linux prohibits user login:

After user login is prohibited, the user cannot log in to the system, but can log in to ftp, SAMBA, etc. When we perform system maintenance under Linux, we hope that individual users or all users cannot log in to the system to ensure that the system operates normally during the maintenance period. At this time we will prohibit users from logging in. ​

passwd -l lynn

This means locking the lynn user so that the user cannot log in. ​

passwd -u lynn

The above is to unlock the locked user lynn, and the user can log in. ​​

vi /etc/passwd

change to:

lynn❌500:500::/home/lynn:/sbin/nologin

The user will no longer be able to log in. ​

touch /etc/nologin

Users other than root cannot log in.