sh
The standard Unix shell name: whatever program /bin/sh points to, expected to behave as the POSIX standard describes.
In more detail
The original sh was the Bourne shell; today /bin/sh is a link to some shell that follows the POSIX rules. On Debian and Ubuntu it is dash, on Alpine it is ash from BusyBox, and on macOS it is bash 3.2 running in its POSIX mode. A script whose shebang says sh must avoid bash-only features, because the shell that actually runs it may not have them.
Example
sudo sh -c 'echo /opt/homebrew/bin/bash >> /etc/shells'Related terms
- POSIX — A standard that describes the commands, shell and programming interface a Unix-like operating system should offer.
- Bash — The GNU shell: a program that reads commands, typed or from a script, and runs them.
- Debian Almquist shell — A small, fast POSIX shell, called dash, that Debian and Ubuntu use as /bin/sh.
- Almquist shell — A minimal POSIX shell, called ash, found as /bin/sh in BusyBox and in Alpine Linux containers.
- bashism — A bash-only feature, such as [[ ]], arrays, (( )) or process substitution, used in a script that claims to be POSIX sh.
Taught in
- What A Shell Is, And What Bash Is — Bash Scripting & Command Line Automation
- Which Shell Am I In, And Getting Bash Five — Bash Scripting & Command Line Automation
- Moving Around: pwd, ls, cd And Paths — Bash Scripting & Command Line Automation
- Making, Copying, Moving And Removing — Bash Scripting & Command Line Automation
- Help, History, Completion And Aliases — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- Arrays, And Why Dollar At Is Not Dollar Star — Bash Scripting & Command Line Automation
- Shell Variables, The Environment And export — Bash Scripting & Command Line Automation
- Shebangs, Permissions And Three Ways To Run — Bash Scripting & Command Line Automation
- Exit Codes, And What Success Means — Bash Scripting & Command Line Automation
- Conditionals: test, Brackets, Double Brackets, case — Bash Scripting & Command Line Automation
- Loops: for, while, until, break, continue — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation
- Functions, local And declare — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- Option Parsing With getopts — Bash Scripting & Command Line Automation
- set -e, set -u And pipefail: Promises And Traps — Bash Scripting & Command Line Automation
- trap, Cleanup And Temporary Files — Bash Scripting & Command Line Automation
- Debugging: set -x, bash -n And Reading The Error — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation
- eval, And What To Use Instead — Bash Scripting & Command Line Automation
- Permissions And Ownership — Bash Scripting & Command Line Automation
- find And xargs — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation