Skip to content

How to Block or Disable Normal User Logins in Linux?

2 min read

To Block User Logins Using /etc/nologin File


This can be used to block user login by manually creating the file as follows.

# vi /etc/nologin

Add the message below to the file, which will be shown to users attempting to log on to the system.

The Server is down for a routine maintenance. We apologize for any inconvenience caused, the system will be up and running in 1 hours time. For more information, contact the system admin admin@ucartz.com. 

Now you can test if it all works; as you can see from the screenshot below, a normal user ucartz is not able to log in.

To Block User Logins Using no login Shell

This method works a little differently: it only blocks a user from accessing a shell. But he or she can log on to the system via programs such as ftp that do not necessarily require a shell for the user to connect to a system.

Additionally, it can allow you to block shell access to specific users in special scenarios.


On RHEL/CentOS/Fedora

Simply use chsh (change shell) command to change the user's shell in /etc/passwd file from something like /bin/bash or /bin/sh to /sbin/nologin meaning refuse a login.

# chsh -s /bin/nologin ucartz


On Debian/Ubuntu

Here, you have to use /bin/false file. The command below changes the user ucartz’s shell to /bin/falsemeaning do nothing (after the user provides login credentials):

$ sudo chsh -s /bin/false ucartz



Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket