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?

Braiam
  • 35,991
dr_
  • 29,602

3 Answers3

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.

JdeBP
  • 68,745
Fox
  • 8,193
  • 4
    There's stuff to say about OpenSolaris and Schillix too. – JdeBP Nov 09 '16 at 08: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 09 '16 at 08: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? –  Nov 09 '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. –  Nov 09 '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.

jlliagre
  • 61,204
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
  • 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. – Stefan Schmidt Oct 20 '22 at 16:26