Linux prohibits a user from logging in to the system.

  

When we do system maintenance, we hope that individual users or all users cannot log in to the system to ensure that the system runs normally during maintenance. At this time we have to prohibit users from logging in.

1. It is forbidden to log in by individual users. For example, lynn users are prohibited from logging in.

passwd -l lynn

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

passwd -u lynn

Unlock the locked user lynn and the user can log in.

2, we modify the /etc/passwd file in the user login shell

vi /etc/passwd

root:x:0:0:root:/root :/bin/bash

bin:x:1:1:bin:/bin:/sbin/nologin

daemon:x:2:2:daemon:/sbin:/sbin/Nologin

adm:x:3:4:adm:/var/adm:/sbin/nologin

lp:x:4:7:lp:/var/spool/lpd:/Sbin/nologin

sync:x:5:0:sync:/sbin:/bin/sync

shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown< Br>

halt:x:7:0:halt:/sbin:/sbin/halt

mail:x:8:12:mail:/var/spool/mail:/sbin/nologin< Br>

uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin

operator:x:11:0:operator:/root:/sbin/nologin< Br>

games:x:12:100:games:/usr/games:/sbin/nologin

lynn:x:500:500::/home/lynn:/bin/bash

Change to:

lynn:x:500:500::/home/lynn:/sbin/nologin

The user cannot log in.

3. All users are prohibited from logging in.

touch /etc/nologin

Users other than root cannot log in.

Copyright © Windows knowledge All Rights Reserved