Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm very new to Ubuntu. I hear people say "shell scripting", "bash scripting".

I wonder are they same? Or they are different?

Thanks in advance.

share|improve this question
There is a useful answer at SO – ShadowGiraffe Nov 30 '14 at 20:17
up vote 20 down vote accepted

Bash (bash) is one of many available (yet the most commonly used) Unix shells. Bash stands for "Bourne Again SHell", and is a replacement/improvement of the original Bourne shell (sh).

Shell scripting is scripting in any shell, whereas Bash scripting is scripting specifically for Bash. In practice, however, "shell script" and "bash script" are often used interchangeably, unless the shell in question is not Bash.

EDIT: Actually, the default scripting shell in Ubuntu is dash, while the default interactive shell (what you get if you pull up a terminal) is Bash. Nonetheless, the two terms are still mostly interchangeable.

share|improve this answer


Shell scripting and Bash scripting are not the same thing, as other shells exist such as sh that can be used to execute a script; a script intended to be executed by Bash should be labelled as a Bash script. The terms are often used interchangeably because Bash, with its extended functionality as compared to sh, is the one most commonly used to execute user scripts in many distributions. However, there are other shells such as the Korn (ksh), C shell (csh) and the Z shell (zsh), but we will not go into them here as a discussion of sh and bash is most relevant to Ubuntu. A great IBM article here goes into more detail on the evolution of shells in Linux and describes well the shell architecture and how shells differ.

Shell Scripting

Sh was the original Unix shell developed by Stephen Bourne; however Debian based systems and Ubuntu considers dash as their sh shell (sh is actually symlinked to dash). In Debian and Ubuntu, because of the speed of sh, it is more often used for critical system procedures and for executing key scripts at startup; for more detail see the Ubuntu wiki. Bash stands for the Bourne Again SHell and was developed later by Brian Fox and much extended the original sh. Fox and others' development of Bash was an important part of the GNU project. See this great discussion of the history of Bash for more information.

It is important to note that both sh and Bash, as used in Ubuntu and other distributions, are POSIX compliant, which means they subscribe to a number of standards about how commands are executed in the Shell. This is to ensure that the results of scripts used in the OS can be predicted reliably, and that the behaviour of the shell can be kept within those POSIX parameters, as that is particularly important for developers. For more information on the standards, see the official documentation.

Often shell scripts have the suffix .sh, even though they are intended to be executed as bash scripts, and have #!/bin/bash at the top of the script. It actually does not matter whether the script is called or my.script, what matters is whether the call to the interpreter is /bin/sh or /bin/bash. Shell scripts can also be called on the command line with either sh or bash.

However, it is important to note that the results can be different depending on which interpreter is called, as not all bash commands will work in sh, whereas most sh commands will work in bash. In general, most users will want to use /bin/bash for their scripts so they can take advantage of the extended feature set; system scripts can be executed with /bin/sh if it is required.

Resources for Bash Shell scripting

It is sometimes difficult to find useful resources online that follow good practice and that give advice that will allow you to create useful scripts. After man bash, some of the most important resources are Greg's wiki, Bash hackers and Steve Parker's recent book on Shell scripting that focuses mainly on Bash and is published by O'Reilly. A good introduction is also undertaken by the Bash beginner's Guide.

share|improve this answer
This answer is actually superior to mine (the accepted answer), mine just came a week before this one. – Hilton Shumway Dec 17 '15 at 18:31
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Mar 29 11:53 /bin/sh -> dash*
$ ls -l /bin/dash
-rwxr-xr-x 1 root root 109768 Mar 29 11:53 /bin/dash*
$ ls -l /bin/bash
-rwxr-xr-x 1 root root 955024 Apr  3 08:58 /bin/bash*

This shows that 'sh' is a symlink to 'dash', and that /bin/bash, which is the default interactive shell on Ubuntu, is an executable that is almost 9 time bigger than /bin/sh.

Indeed, 'man sh' (1590 lines) vs 'man bash' (5459 lines) reveals that bash is a large superset of the traditional 'sh'.

Read more here:

share|improve this answer

There are multiple shells available for Ubuntu, like bash, zsh, ksh, tcsh and csh.

So anytime someone says shell, he is talking about one of those. However, those shells differ a bit from each other. So, when someone talks about bash scripting, he's using a shell, but when someone is talking about shell scripting, he isn't per se using bash. But as bash is commonly used in scripting for Ubuntu, he usually is. Moreover, the different shells are the same in lots of aspects, so it usually doesn't matter.

share|improve this answer
PLEASE JUSTIFY YOUR DOWN VOTES! – fromnaboo Aug 9 '12 at 19:31
I think that you got a downvote because OP is probably new to scripting. So terms like zsh, ksh tcsh are probably a bit hard for OP at this point. Also, the formatting in your answer could be better. – Exeleration-G Aug 21 '12 at 9:47
fromnaboo, please do not use caps and yell. @Exeleration-G The downvote could not have been from the OP as the OP lacks 125 reputation. – hexafraction Aug 21 '12 at 12:55
True, I was just saying that some other user could have thought: this answer is not good for OP, so I'll downvote it. – Exeleration-G Aug 21 '12 at 14:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.