Dash
Debian Almquist Shell
Lightweight POSIX-compliant shell, fast and minimal
Overview
Dash (Debian Almquist Shell) is a POSIX-compliant shell that is much smaller and faster than bash. Ubuntu and Debian use dash as /bin/sh for system scripts, providing faster boot times and script execution.
Quick Facts
| Full Name | Debian Almquist Shell |
| Category | Posix |
| POSIX Compliant | Yes |
| Config File | .profile (via /bin/sh) |
| Default On | Ubuntu (/bin/sh), Debian (/bin/sh) |
| First Release | 1997 |
Who Should Use Dash?
- System scripts - Fast execution for init scripts
- Container developers - Minimal image size
- Performance optimization - Scripts that need speed
- Embedded systems - Resource-constrained environments
Installation
Install dash for faster script execution.
# Install on Debian/Ubuntu (usually pre-installed as /bin/sh)
sudo apt install dash
# Install on macOS
brew install dash
# Install on Fedora
sudo dnf install dash
# Check if sh is dash
ls -la /bin/sh
# On Debian/Ubuntu: /bin/sh -> dashBasic Usage
Dash follows POSIX strictly.
#!/bin/dash
# Variables (no declare, no local outside functions)
NAME="World"
echo "Hello, $NAME!"
# No arrays! Use positional parameters
set -- apple banana cherry
echo "$1" # apple
# Arithmetic
result=$((5 + 3))
echo "$result"
# Functions
greet() {
local name="$1" # local only in functions
echo "Hello, $name!"
}
# No [[ ]], use [ ] or test
if [ "$NAME" = "World" ]; then
echo "Match!"
fiConfiguration
Dash is not intended for interactive use.
# Dash reads ~/.profile for login shells
# ~/.profile
PATH="$HOME/bin:$PATH"
export PATH
# Note: Dash has no interactive features
# - No command history editing
# - No tab completion
# - No prompt customization beyond PS1
# Use dash for scripts, not interactive shells
# In scripts, prefer:
#!/bin/dashKey Features
Speed
4x faster startup than bash, faster script execution
Small Size
Much smaller binary than bash (~150KB vs ~1MB)
POSIX Compliance
Strict adherence to POSIX standard
Low Memory
Minimal memory footprint for embedded use
FAQ
Why does Ubuntu use dash for /bin/sh?
Dash is much faster than bash for script execution. Ubuntu switched to dash for system scripts to improve boot times and overall system performance.
Can I use dash as my interactive shell?
Technically yes, but dash lacks interactive features like history editing, tab completion, and line editing. It's designed for scripting, not interactive use.
Summary
Key takeaways for Dash:
- Fastest POSIX-compliant shell available
- Default /bin/sh on Debian and Ubuntu
- Ideal for system scripts and containers
- Not suitable for interactive use
Official Documentation
For authoritative information, refer to the official documentation: