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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. laptop-detect Command Examples in Linux
  2. Failed to start LSB: Bring up/down networking – On restarting network service CentOS/RHEL (DHCP client)
  3. Linux OS Service ‘cpuspeed’
  4. udisksctl: command not found
  5. CentOS / RHEL 7 : How to change the verbosity of debug logs during booting
  6. firebase – Test, manage, and deploy Firebase projects from the command-line
  7. flatpak Command Examples in Linux
  8. KVM Virsh Command Examples on CentOS and RHEL
  9. ipset Command Examples in Linux
  10. Sample /etc/services file in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • gml2gv Command Examples
  • glow Command Examples
  • glib-compile-resources Command Examples
  • glances Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright