As I understand, in Linux /bin/sh(points to /bin/dash in some distributions) is the default system shell. Does it run (SysV) init scripts? Anything else? Any why isn't root user shell(/bin/bash in Debian according to /etc/passwd) used for those tasks? The reason I ask is that I read the LPIC-1 study guide and it said that:

The default system shell is used by the Linux system to run system shell scripts, typically at startup.

I had an impression that startup happens under root user and thus root user shell is used.

  • 2
    Why should the shell that root uses for interactive stuff be the same as the shell used for startup scripts? – muru Jan 7 '17 at 11:55
  • When I think about it, then you are obviously correct. They use the shell defined on the shebang line. However, startup scripts are run under the root user, aren't they? – Martin Jan 7 '17 at 13:16

You would want these scripts to not depend on the default shell of any user, including root. If the admin changed the default shell of root, it should not affect the system in any unexpected way, including startup.

This is true of all scripts, and is why all scripts should start with #! to specify what interpreter to use.

  • Not ever changing the login shell of root, so that people get a consistent behaviour (without unpleasant surprises because suddenly the shell is someone's personally preferred login shell, or the shell is some third-party shell on an unmounted filesystem), is one of the reasons that the BSDs have a toor user, which is the superuser with a potentially customized shell and a different USER value in the login session processes' environments. – JdeBP Jan 7 '17 at 13:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.