Linux nologin command - restrict user login

nologin command: restrict user login

nologin command Function Description

Use the nologin command to restrict certain users from logging into the system via the Shell. If the file /etc/nologin.txt exists, display its contents to the user instead of the default message.

nologin command Syntax

nologin 

nologin command demo

Restrict users from logging in.

[root@deepinout ~]# nologin 

Linux banned user login:

After disabling user login, users cannot login to the system, but they can login to ftp, SAMBA, etc. When we do system maintenance under Linux, we want individual users or all users to be unable to log in to the system to ensure that the system runs normally during the maintenance period. This is the time when we want to disable user login.

Disable individual user login, for example, disable lynn user login

passwd -l lynn

This means that the lynn user is locked out so that the user cannot log in.

passwd -u lynn

The above is to unlock the locked user lynn, the user can login now.

We modify the user login shell in the /etc/passwd file by

vi /etc/passwd

Changed to:

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

The user will not be able to log in.

Disable all user logins

touch /etc/nologin

Users other than root can’t log in anymore.

Like(2)
Linux Login Logout Command
Linux login commandLinux logout commandLinux nologin commandLinux exit commandLinux sulogin commandLinux rlogin commandLinux poweroff commandLinux ctrlaltdel CommandLinux shutdown commandLinux halt commandLinux reboot commandLinux init commandLinux runlevel commandLinux telinit command
Linux File Management Command
Linux cat commandLinux tac commandLinux nl commandLinux more commandLinux less commandLinux head commandLinux tail commandLinux rev commandLinux fold commandLinux fmt commandLinux expand commandLinux pr commandLinux sort commandLinux uniq commandLinux cut commandLinux comm commandLinux diff commandLinux join commandLinux diff3 commandLinux cmp commandLinux colrm commandLinux paste commandLinux mkdir commandLinux tr commandLinux split commandLinux csplit commandLinux tee commandLinux unexpand commandLinux patch commandLinux awk commandLinux sed commandLinux od commandLinux pwd commandLinux cd commandLinux ls commandLinux dir commandLinux dirs commandLinux touch commandLinux rmdir commandLinux cp commandLinux mv commandLinux rm commandLinux install commandLinux tmpwatch commandLinux file commandLinux du commandLinux wc commandLinux tree commandLinux cksum commandLinux md5sum commandLinux sum commandLinux dirname commandLinux mkfifo Command
Cron Expressions
Cron Expression to Run Every Day at 12 PMUnderstanding Vue Cron ExpressionsUnderstanding JS Cron ExpressionsA Comprehensive Guide to Cron Expressions for Scheduled TasksUnderstanding Linux Cron ExpressionsUnderstanding Quartz Cron ExpressionsCron ExpressionCron Time ExpressionCron Expression ParsingCron Expression: Executing a Task Every SecondCron Expression for Every Minute ExecutionCron Expression to Execute Every 10 MinutesCron Expression: Executing Every HourCron Expression to Execute Once a YearCron Expression: How to Schedule a Task to Run Daily at Midnight?