• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

What’s different between /bin/false and /sbin/nologin as nologin user’s shell

by admin

At times, we may need a user account with a password for authentication with a system, but do not require an interactive shell with that username. This helps in preventing the user account being used for logging in to the system with that password. In those scenarios, we can set the user’s shell to /sbin/nologin or /bin/false. If the user tries to log in to the system, the nologin shell closes the connection of the user.

An example of such a situation could be a mail server, where a user account is needed to store mail and passwords for the user to authenticate with the mail client and retrieve their mail; however, if the /sbin/nologin shell is assigned, then the user cannot log in to the system using that account.

Since both commands return non-zero, there is not so much difference. Originally, /bin/false has been created for a general command as it always returns non-zero. Then, seems it is used as nologin user’s shell before creating /sbin/nologin.

On the other hand, /sbin/nologin has been created for nologin user’s shell, it has a feature to give a message in /etc/nologin.txt. Using /sbin/nologin is recommended for nologin user’s shell, because it is included in /etc/shells.

$ man -k nologin
nologin(5)               - disallow logins
nologin(8)               - politely refuse a login
pam_nologin(8)           - No Login PAM module
$ man -k false
...
false(1)                 - Return false value

Filed Under: Linux

Some more articles you might also be interested in …

  1. eject Command Examples in Linux
  2. /proc/cpuinfo file explained
  3. How to add Source, Services and Ports to Firewall Zone in CentOS/RHEL 7 and 8
  4. toilet Command Examples in Linux
  5. apt-mark: command not found
  6. ntpdate Command Examples in Linux
  7. dracut: command not found
  8. How to Install and configure telnet in RHEL / CentOS 5,6
  9. dar Command Examples in Linux
  10. How To Increase The Retention Of “sar” Data To ‘N’ Days in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright