What is /bin/dash? I noticed that the default system shell /bin/sh was changed to /bin/dash. Why was this change made?
Dash is an acronym for Debian Almquist shell (dash). It is a Unix and Linux shell which is much smaller than bash but still aiming at POSIX-compliancy. dash is a POSIX-compliant implementation of /bin/sh that aims to be as small as possible. dash is a direct descendant of the NetBSD version of ash (the Almquist SHell), ported to Linux in early 1997. It was renamed to dash in 2002.
From the dash man page:
dash is the standard command interpreter for the Linux system. The current version of dash is in the process of being changed to conform with the POSIX 1003.2 and 1003.2a specifications for the shell. This version has many features which make it appear similar in some respects to the Korn shell, but it is not a Korn shell clone. Only features designated by POSIX, plus a few Berkeley extensions, are being incorporated into this shell.
Starting with DebianSqueeze and Ubuntu 6.10, the default shell will be dash. The default system shell, /bin/sh, was changed to /bin/dash due to the following technical reasons:
- To speed up the system boot time. The reason is that dash starts faster than bash, and the shell is started quite a lot of times during boot. Measurements showed that they run equally fast, so the improved boot time must be due to dash doing less work during initialization.
- It requires less disk space but is also less feature-rich.
- It depends on fewer libraries.
- It is believed to be more reliable in the case of upgrade problems or disk failures.
A Note About Bash Specific Scripts
It is recommend that to avoid errors with your own Bash-specific scripts you can use the shebang line as follows:
However, Ubuntu wiki recommends that:
Developers of shell scripts adhere to the POSIX standard, omitting those items flagged as XSI extensions. Doing so will improve portability to a variety of Unix systems, and will provide assurance that problems you encounter will be treated as bugs rather than as undocumented features.
Test all your scripts and see if they will break once /bin/sh defaults to /bin/dash using virtualization or test machine.
- Dash page from the Debian wiki.
- Dash as /bin/sh page from the Ubuntu wiki.
- Proposed release goal: Switch to dash as /bin/sh to speed up the boot.
- man dash
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
|Category||List of Unix and Linux commands|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|