Any reason not to change the root shell to bash?

The default shell for root (at least on Yosemite) is /bin/sh. Would there be any problem to changing it to bash (or better yet zsh)? As far as a I know bash at least is backward compatible.

I need a more robust shell to run things like iTerm's shell integration.


Solution 1:

The path of the shell is the only substantial difference I can see between sh and bash - if you look carefully at /bin/sh on OS X, it's really bash (perhaps compiled with a flag to make it know it's filling in for sh since the binaries are slightly different).

mac me$ md5 /bin/sh /bin/bash
MD5 (/bin/sh) = 2cc3c26641112c1bd0173f396b7d7662
MD5 (/bin/bash) = 5d7583d80e5314ac844eedc6d68c6cd7
mac me $ ls -l /bin/sh /bin/bash
-r-xr-xr-x  1 root  wheel  628496 Aug 28 02:02 /bin/bash
-r-xr-xr-x  1 root  wheel  632672 Aug 28 02:02 /bin/sh
mac me $ sh --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.
manoa mac me $ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

So, if somehow iTerm is barfing on /bin/sh even though it's already bash, you could change shells. I'd say running things from your user with sudo -H is always better than enabling root, but that's a discussion for another thread:

  • Is it 'OK' to use the root user as a normal user?
  • OSX Mavericks Root User

If you want to test the change:

  • Change my shell to a different bash version at /usr/local/bin/bash?
  • chsh doesn't change $SHELL