What is Dash (/bin/dash) Shell on Linux?

Linux TLDR
Last Updated:
Reading time: 3 minutes

You think you always interacted with Bash? Wrong; under the hood, there was a savior to provide you speed and better efficiency, known as Dash.

What is the Dash Shell in Linux?

Dash (or the “Debian Almquist shell“) is a UNIX/Linux shell that complies with the POSIX standard and earned the title of “lightest shell” (10x smaller) compared to Bash.

It’s a direct descendant of Almquist shell (also known as A shell, ash, and sh) ported by Herbert Xu from NetBSD to Debian/Ubuntu Linux in late 1997.

Due to its small size, Ubuntu 6.10 (in 2006) and Debian 6 (in 2011) adopted Dash as the default “/bin/sh” shell to boost script execution and system startup.

What About Bash and the “/bin/sh” Shell?

First, don’t confuse Bash and Shell; both are different programs. Shell is the original UNIX shell located at the “/bin/sh” path, while Bash is the extended version of shell located at the “/bin/bash” path.

In most Linux distributions, Bash (like Debian or Ubuntu) or its alternatives like ZSH (like Kali Linux or Manjaro) and Fish are used as the default interactive login shell.

Bash (or its alternatives) is a full fledged shell interpreter that provides many more features and functionality than the standard “/bin/sh” shell, but at a price, and this price was the shell size.

In the following picture, you can see the difference between the size of Bash (10x bigger) and shell:

Comparing the sizes of bash and sh

But both have their own merits and demerits. For example, due to its large size, Bash has more functionality and features compared to traditional shells (hence, being the default login shell), but is mostly used as an interactive login shell where users can interact from the terminal.

However, being small is not always bad, and since Dash is smaller in size and lacks a few features but is still better than the original “/bin/sh” shell, that is the reason you will find that the “/bin/sh” shell is a symbolic link pointing towards the Dash shell.

Comparing the file types of bash and sh
💡
Systems like Fedora or Manjaro don’t point the “/bin/sh” shell towards Dash; instead, they point it towards the “/bin/bash” shell.

Once again, let me tell you that Bash (and its alternatives) are used as an interactive login shell (the one with which you interact with the terminal), providing more features, while Shell (a symbolic link pointing towards Dash in Debian and Ubuntu) is used for script execution and system boot.

Let’s talk about a few features of Dash.

Significant Features

The following are known features of Dash:

  • Promise significant speed.
  • Increase the speed of system boot time.
  • Smaller in size but having fewer features.
  • Depends on fewer system libraries (it only relies on “libc“), unlike bash, which requires more libraries to execute a shell script.
  • More reliable with an upgrade problem or broken system.

Speed Comparison of Bash and Dash

Until now, you have heard a lot of times that Dash is faster than Bash, but that doesn’t mean anything until you actually test it.

For that, you can use the following line of codes, which will create 10,000 subshells one after another (it does not determine the speed of the boot process).

for a in `seq 10000`; 
do ( :; ); 
done

Copy and paste the above line of codes into a shell script with the name “shspeed” using your choice of text editor, like Vim or Nano.

$ vim shspeed

#OR

$ nano shspeed

Output:

shspeed script file

Save and close it, and give the script executable permission using the chmod command.

$ chmod u+x shspeed

Output:

Assigning executable permission to the shspeed script

Lastly, execute this script using the Bash and Dash shells, using the time command to check the execution speed.

$ time bash shspeed
$ time dash shspeed

Output:

Comparing the speed of Bash and Dash

As you can see, the same script executed in Bash took 7.2 seconds, while in Dash it took 5 seconds.

Note that this result varies on various factors like system resources, background processes, system type, and many more, so expect to have different results in your system, but surely the result for Dash will be faster than Bash.

I think I’ve said enough about Dash in this article.

If you want to add something to this article or have any suggestions, the comment section is always open for you.

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.