Change default Linux `dash` shell to `bash`.

Ubuntu ≥ 17.10 (including Ubuntu 18.04) use Dash as the default shell, which can surprise users having scripts with #!/bin/sh shebang, as they suddenly stop working where Bash was required. Ubuntu 10.04 - 17.04 default shell is Bash. Dash startup time is faster due to the 93% smaller codebase vs. Bash. Dash also may be less likely to have security vulnerabilities due to the smaller codebase. However on modern computers I simply prefer the Bash ease of use.

Specify shell to run script

The default Linux shell is selectable in the shebang at the top of the .sh file. When I distribute .sh files (say, via GitHub) I almost always use shebang #!/bin/bash.

here is an example script requiring Bash


[[ 1 == 0 ]] &&  { echo true; }  || { echo false; }

In Dash this script will simply crash due to incompatible syntax, but Bash runs this happily.

The “shebang” is the first line in the script file selecting the executable to run the script with.

Many people simply use


Which just means use any shell installed, which will break for scripts needing Bash where Bash isn’t the default.

If your script is more complicated, you might consider using shebang


if appropriate.


Check which shell is default

  1. open the default shell from Terminal

  2. see if it’s Bash by using a command only Bash understands

    [[ 1 == 0 ]]  || echo false

It’s generally not appropriate to change the default shell for a user, as this can slowdown their entire system if for example Dash default is replaced by Bash. Nonetheless, one can set per-user default shell to Bash assuming username is jane by:

usermod --shell /bin/bash jane