Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just noticed that on OS X 10.6.4 root's shell is set to /bin/sh. Is there a security issue or something with running Bash?

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

I believe that for Unix compatibility reasons, the default root shell is /bin/sh.

See http://en.wikipedia.org/wiki/Bourne_shell

At one point, /bin/sh was a zsh shell, I believe. Apple changed it to bash because zsh wasn't POSIX compliant or somesuch.

EDIT:

The Makefile sourcecode, showing that /bin/sh is built from bash source.

EDIT #2:

Bored, I checked. It looks like Mac OS X 10.1.5 was the last version to use zsh for /bin/sh. It was changed to bash in 10.2.

share|improve this answer
add comment

Isn't /bin/sh Bash?

Do a 'ls -lisa' in /bin. Then do a './sh -version' in the directory and sh will identify itself as the GNU bash.

share|improve this answer
    
According to stat -f "%N: %i" /bin/sh /bin/bash, they aren't hardlinks of each other and an md5sum of the two files produces different checksums. Even if /bin/sh were a symlink or hardlink to /bin/bash, Bash checks the name it was run under and activates a compatibility mode if the name is sh. –  Chas. Owens Jun 18 '10 at 16:01
    
@Chas. Andrew is correct, they are the same. Proof: opensource.apple.com/source/bash/bash-80/Makefile –  ghoppe Jun 18 '10 at 16:22
    
@ghoppe explain the different md5sums. And the fact that running set -o vi turns off tab completion when run under sh, but not bash. Saying sh is bash ignores the fact that they behave differently, which is the point of this question. Why is OS X using sh, and is it unsafe to change it use bash. I don't doubt that they are both built from the same source, but they are not the same. –  Chas. Owens Jun 18 '10 at 18:09
    
@Chas if you check the sourcecode I linked, you'll see that bin/sh is built with $(Extra_Configure_Flags) --enable-strict-posix-default I'm pretty certain this is why the md5 checksums are different and they exhibit slightly different behaviour. I'm not enough of a unix geek to know why set - o vi behaves as it does, but I did find this list of POSIX mode differences: gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html –  ghoppe Jun 21 '10 at 14:18
add comment

Ubuntu uses dash as the default system shell for speed instead of sh. I guess if it is indeed sh, then it is probably the same reason.

There are good reasons here why bash is not really the best choice as the default system shell: https://wiki.ubuntu.com/DashAsBinSh

share|improve this answer
1  
The myriad features in Bash need facilities to initialize them and code to support them. On Ubuntu Lucid x86, both bash and dash are dynamically linked, stripped ELF binaries, but bash at 800kB is ten times the size of dash. –  msw Jun 18 '10 at 16:03
add comment

Setting root's login/interactive shell to /bin/bash has no affect on shell scripts that have #!/bin/sh as their shebang line. For those scripts whatever file acts as /bin/sh whether it's a standalone executable or a symlink or hard link will be used to interpret that script. Likewise for scripts run from the command line in this manner: sh script.

It's perfectly fine to set the root user's interactive shell to be /bin/bash.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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