Change default Linux dash shell to bash.

1 minute read

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.

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

Set per-user default shell

Assuming username is jane, set default shell to Bash by:

usermod --shell /bin/bash jane

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.

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.

Leave a Comment