Why is "/bin/false" required to install the packages?

I'm installing ntp package by giving the configuration as

useradd -c "Network Time Protocol" -d /var/lib/ntp -u 87 \ -g ntp -s /bin/false ntp

In the above command what does /bin/false signify?

1 Answer

In this kind of situation, always start from the man page.

From man useradd:

-s, --shell SHELL: The name of the user's login shell. The default is to leave this field blank, which causes the system to select the default login shell specified by the SHELL variable in /etc/default/useradd, or an empty string by default.

Setting the user's login shell as /bin/false (or /usr/sbin/nologin) is another way of saying the user can not login interactively.

Assuming ntp is not a physical user, this is fairly common for accounts only needed for services.

Also note that /bin/false is an executable (comes with coreutils package) that does nothing but exiting with exit status ($?) 1 if called.

Another point is, if the -d option (creating home directory) is not needed, you can take the safer option to create a system user account.

from man useradd:

-r, --system Create a system account.
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like