23

/bin/sh, the Bourne shell created in 1977, used to be the default shell for Unix systems.

Nowadays this file still exists but mostly just as a symbolic link to the default POSIX-compatible shell installed on the system:

  • on RHEL/CentOS it points to /bin/bash, the Bourne Again shell
  • on Ubuntu Linux it points to /bin/dash, the Debian Almquist shell
  • on Debian it points to /bin/dash (6.0 and later; older Debian releases had it point to /bin/bash)

Which made me curious: Is there a Unix system, or Linux distro, that still provides a binary for /bin/sh?

5

3 Answers 3

30

/bin/sh is not always a symlink

NetBSD is one system where /bin/sh is not a symlink. The default install includes three shells: the Korn shell, the C shell, and a modified Almquist shell. Of these, the latter is installed only as /bin/sh.

Interix (the second POSIX subsystem for Windows NT) does not have /bin/sh as a symlink. A single binary of the MirBSD Korn shell is linked twice as /bin/sh and /bin/mksh.

FreeBSD and its derivative TrueOS (formerly PC-BSD) have the TENEX C shell as both /bin/csh and /bin/tcsh, and the Almquist shell as (only) /bin/sh. No symlink there, either.

OpenBSD has the (original) C shell as /bin/csh and the PD Korn shell linked thrice as /bin/sh, /bin/ksh, and /bin/rksh. Also no symlink.

5
  • 4
    There's stuff to say about OpenSolaris and Schillix too. Commented Nov 9, 2016 at 8:34
  • I would have been quite content for you to have had the points. No worries. @schily is an occasional Stack Exchange contributor. Maybe xe will fill in Schillix and OpenSolaris. Commented Nov 9, 2016 at 8:50
  • I fail to understand why a symlink is that important. If in the /bin directory I do ln ksh sh, there is a hardlink called sh, it is not a symlink. Is it a sh binary? Commented Nov 9, 2016 at 18:43
  • I believe that what is intended with some binary placed or symlinked in '/bin/sh' is what matters. All systems AFAIK have a /bin/sh. None AFAIK ships with an old ATT sh. As an example, dash in debian systems is intended to be as close as is possible to an old /bin/sh. Commented Nov 9, 2016 at 18:48
  • You are taking issue with the premise of the question. Such commentary is mis-placed against an answer. Commented Nov 10, 2016 at 12:13
14

Solaris 10 still has the legacy Bourne shell binary as /bin/sh, and this is definitely not a POSIX compatible shell.

Hopefully, Solaris 11 broke this annoying tradition by providing ksh93 as /bin/sh.

0
4

This OSX box has /bin/sh as:

$ ls -alF /bin/sh -r-xr-xr-x 1 root wheel 632672 May 5 2016 /bin/sh* $ uname -a Darwin AUS-LM-000421.local 15.6.0 Darwin Kernel Vers... 
2
  • 2
    Interestingly, both those files report being GNU bash 3.2.57(1)-release on my laptop, but differ by a few kilobytes (632672 bytes for /bin/sh vs 628496 bytes for /bin/bash). Commented Nov 14, 2016 at 19:51
  • 1
    From the man page of sh on macOS: »sh is a POSIX-compliant command interpreter (shell). It is implemented by re-execing as either bash(1), dash(1), or zsh(1) as determined by the symbolic link located at /private/var/select/sh.« On my system /private/var/select/sh points to /bin/bash. Commented Oct 20, 2022 at 16:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.