What Is /bin/sh
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 11, 2026
Key Facts
- Stephen Bourne created the original Bourne shell in 1977 at AT&T Bell Labs
- POSIX (Portable Operating System Interface) established /bin/sh as the standard shell specification
- On Linux systems, /bin/sh is often symlinked to dash (Debian Almquist Shell) or bash
- System scripts and cron jobs use /bin/sh as the default interpreter for portability
- The Bourne shell introduced features like pipes, redirection, and shell scripting that remain standard today
Overview
/bin/sh is the system shell interpreter, a command-line program that reads and executes user commands and shell scripts on Unix and Unix-like systems. Created by Stephen Bourne in 1977 at AT&T Bell Labs, the Bourne shell became the standard interactive and scripting shell for decades and influenced most modern shell designs.
On contemporary Linux and Unix systems, /bin/sh typically exists as a symbolic link pointing to another shell such as bash (Bourne Again Shell), dash (Debian Almquist Shell), or other POSIX-compliant shells. The POSIX standard formally specified /bin/sh as the location where a standards-compliant shell must be available, making it essential for system portability and script compatibility.
How It Works
The /bin/sh shell operates through a straightforward process when you execute a command or script:
- Command Reading: /bin/sh reads input from the terminal (interactive mode) or from a script file (non-interactive mode), processing each line sequentially.
- Parsing and Tokenization: The shell parses the input into tokens, identifying commands, arguments, operators, and special characters like pipes (|) and redirections (>, <).
- Variable Expansion: /bin/sh expands variables, wildcards, and special parameters before executing commands, allowing dynamic script behavior and file pattern matching.
- Command Execution: The shell locates the executable command in the system PATH directories and executes it with the provided arguments, managing file descriptors for input/output redirection.
- Exit Status Management: /bin/sh captures the exit status of executed commands, allowing scripts to use conditional logic based on success or failure of previous operations.
Key Comparisons
| Feature | /bin/sh (POSIX) | bash (Bourne Again) | zsh |
|---|---|---|---|
| POSIX Compliant | Yes (by definition) | Yes, with extensions | No, custom syntax |
| Script Portability | Maximum portability across Unix systems | Portable with bashisms | Requires zsh installed |
| Performance | Lightweight and fast execution | Slightly heavier, more features | More resource intensive |
| Default System Usage | Standard for system scripts | Common interactive shell | Advanced user preference |
| Interactive Features | Minimal, POSIX-only | History, completion, advanced editing | Extended features and themes |
Why It Matters
- System Stability: Using /bin/sh for system scripts ensures reliability across different Unix variants and distributions, as all systems must provide a POSIX-compliant shell at this location.
- Portability Guarantee: Scripts written for /bin/sh will execute identically on Linux, BSD, macOS, Solaris, and other Unix-like systems without modification.
- Performance Critical: System administrators and developers choose /bin/sh for automated tasks like cron jobs, startup scripts, and deployment processes because of its minimal overhead and universal availability.
- Security Consideration: The standardized nature of /bin/sh makes it a target for security audits and hardening, with vulnerabilities receiving immediate attention across the entire Unix ecosystem.
/bin/sh remains foundational to Unix philosophy and system administration. Whether you're writing shell scripts, configuring system automation, or troubleshooting Unix systems, understanding /bin/sh provides essential knowledge for effective system interaction and scripting. The shell's longevity since 1977 demonstrates the enduring importance of its core design principles.
More What Is in Daily Life
Also in Daily Life
More "What Is" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- POSIX Shell SpecificationPublic Domain
- Bourne shell - WikipediaCC-BY-SA-4.0
- GNU Bash ManualGFDL-1.3
Missing an answer?
Suggest a question and we'll generate an answer for it.