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?

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.

  • 4
    There's stuff to say about OpenSolaris and Schillix too. – JdeBP Nov 9 '16 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. – JdeBP Nov 9 '16 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? – sorontar Nov 9 '16 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. – sorontar Nov 9 '16 at 18:48
  • You are taking issue with the premise of the question. Such commentary is mis-placed against an answer. – JdeBP Nov 10 '16 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.

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
    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). – Gaurav Nov 14 '16 at 19:51

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.