Understanding bash vs dash — What Every DevOps Engineer Should Know

When writing shell scripts or running automation tools like Ansible, you’ll often see /bin/sh, /bin/bash, or even errors like: This confusion stems from differences between bash and dash — two popular Unix shells. Let’s explore what they are, how they differ, and when it matters. What is bash ? Bash stands for Bourne Again Shell. It’s: Key Features of Bash: What is dash ? dash stands for Debian Almquist Shell. It’s: What dash lacks: bash vs dash: A Side-by-Side Feature bash dash POSIX compliant Mostly Fully Arrays Yes No [[ … ]] Yes No set -o pipefail Yes No Brace expansion ( {1..5} ) Yes No Speed Slower Faster Installed by default Most distros Debian/Ubuntu Example That Works in Bash but Fails in Dash This will fail in dash (/bin/sh on Ubuntu) with: It works fine in bash. Why This Matters in DevOps & Ansible ? In tools like Ansible, the shell module runs commands via /bin/sh by default. On Ubuntu/Debian systems, /bin/sh → dash, which means: How to Switch /bin/sh to Bash (if needed) This will update /bin/sh → /bin/bash. Best Practices #ansible #skillupwithsachin #blogs #bash #dash Youtube: https://www.youtube.com/@skillupwithsachin