Skip to content

This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!


Dash is a small, fast, secure, and POSIX compliant implementation of /bin/sh. Dash is not Bash compatible: be careful of bashisms.


Table of contents


# emerge -a app-shells/dash
# pacman -S dash


Dash can be optionally defined as the default shell for the system.

In this case, one can identify the scripts containing features of Bash that aren't supported in Dash ('bashisms'), those scripts will not work without being explicitly pointed to /bin/bash.

  • Install checkbashisms:

    # apk add checkbashisms





    # emerge -a dev-util/checkbashisms
    # nix-env -iA nixos.checkbashisms
    # nix-env -iA nixpkgs.checkbashisms
    # pacman -S checkbashisms



    # xbps-install -S checkbashisms



  • Check installed scripts with a #!/bin/sh shebang that may need modification:

    # pacman -S checkbashisms
    $ find /usr/bin/ -type f -perm -o=r -print0 | xargs -0 gawk '/^#!.*( |[/])sh/{printf "%s\0", FILENAME} {nextfile}' | xargs -0 checkbashisms
    $ pacman -Qlq # can be used to list all pacman-installed files.

Finally, switch the system default shell:

# su
# eselect sh list
# eselect sh set dash
# exit

# ln -sfT dash /usr/bin/sh

Updates of Bash will overwrite /bin/sh with the default symlink. To prevent this, use the following pacman hook, which will relink /bin/sh after every affected update:
# sudo vi /etc/pacman.d/hooks/dashbinsh.hook
    > [Trigger]
    > Type = Package
    > Operation = Install
    > Operation = Upgrade
    > Target = bash
    > [Action]
    > Description = Re-pointing /bin/sh symlink to dash...
    > When = PostTransaction
    > Exec = /usr/bin/ln -sfT dash /usr/bin/sh
    > Depends = dash


  • Let's consider the following script:

    $ touch yourscript.whatever
    $ echo "echo hello" > yourscript.whatever

    In order to execute it with Dash, run:

    $ dash yourscript.whatever

    If you want to execute it directly, then make sure your script starts with #!/bin/dash (or #!/bin/sh if $ ls -la /bin/sh points to /bin/dash), make this script executable ($ chmod +x yourscript.whatever), and run:

    $ ./yourscript.whatever


You can check your scripts for errors, warnings and suggestions with shellcheck.

  • How to create a dash configuration file like $HOME/.bashrc # or ${ZDOTDIR:-${HOME}}/.zshrc or wherever:

    $ cd
    $ touch .dashrc
    $ vi .profile
        > ...
      + > ENV=$HOME/.dashrc; export ENV

If this cheat sheet has been useful to you, then please consider leaving a star here.