Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

New to Linux and have a few questions about shell scripting:

  • shell
  • C shell
  • Bash shell
  • Bourne shell
  • korn shell

So many "shells"! With respective to these, how do I tell which interpreters my Linux system is configured for? If I don't have support for, say, korn, then how would I configure my system to support it?

Also, which one of these shells is most "active" (most frequently updated & maintained)?

Thanks in advance!

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

The problem you addressed is the very reason why we have the notion of POSIX Compliant Shells and the ability to make "portable" code. As long as you adhere to the POSIX compliant syntax laid out in that link, you can be rest assured that your code is portable.

Having said that, if your intended audience is only Linux, every Linux distro I've ever seen comes with bash as the default shell so you can be fairly confident that a Bash 3.x compliant script will work on just about any Linux distro out there.

share|improve this answer
Thanks SiegeX - exactly what I was looking for! –  pnongrata Feb 4 '12 at 20:41
Debian and its children distros (at least some of them, Ubuntu for sure) now use Dash as /bin/sh. So I would be very careful about assuming that Bashisms will work on "just about any Linux distro out there". See this for some tips regarding how to avoid Bashisms: wiki.ubuntu.com/DashAsBinSh. –  Telemachus Feb 4 '12 at 20:48
@Telemachus I should have clarified that I meant using #!/bin/bash as the interpreter –  SiegeX Feb 4 '12 at 20:57
Out of curiosity, whats the difference between /bin/sh and #!/bin/bash? –  pnongrata Feb 4 '12 at 21:22
The #! line tells the OS which program to run to interpret the script; if you start the script with #!/bin/sh it'll be interpreted by whatever program is installed under the name sh in the directory /bin. By convention, /bin/sh is pretty much guaranteed to be a POSIX-compliant shell (sometimes the original Bourne shell, sometimes dash or bash or zsh or..). So if you start with #!/bin/sh you can count on the POSIX-specified features being available, but cannot count on any particular set of extended features. OTOH if you use #!/bin/bash, you can count on having bash's extensions. –  Gordon Davisson Feb 4 '12 at 21:42
add comment

The first UNIX was at AT&T. The first shell was Bourne shell. It was very cool, but it had some serious limitations.

When the guys at Berkeley started playing with UNIX and tried to make it better, they came out with the C shell. It had a different programming language (though also flawed in it's own way) but was much better at interactive use. Because of its advantages in interactive use, it became very popular in any UNIX that descended from Berkeley UNIX.

C shell (or csh) spawned an open source clone called tcsh. If you use csh, you probably don't use 'true' or original csh, but tcsh.

Meanwhile, the UNIX guys didn't just sit on their hands. Dave Korn (nice guy) created a new shell called... Korn shell. It followed the programming model that Bourne shell created (arguably superior to the csh model). It became very popular, became many people's day to day shell. It became part of the UNIX spec as well. This spawned a fairly popular open source clone called pdksh, which is pretty close (thought not 100%) compatible. Eventually AT&T released the code as open source.

The GNU guys wanted to make their own UNIX-ish system, so they needed a shell, one they could include without worrying about licensing issues. They created bash, the Bourne Again SHell. Mostly compatible with original Bourne, and taking ideas from both Csh and Ksh, it became popular both because of ease of use, and because it came with every Linux. There have been several versions, version 2 is the first very usable one, and it's now on version 4 with new features.

Then there came zsh. It too followed Bourne shell syntax, and copied what was good in Bourne shell, ksh, csh, and bash. It has, arguably, the most advanced syntax with features not found in other shells.

TL;DR So, what to use? If you are coding a startup script, you want to use /bin/sh, which is POSIX/Original Bourne compatible. The language is sparse, but it will run, even if disks such as /usr aren't available.

If not a startup scripts, you have a bit more choice. If you're on just your machine, use anything that's currently available. You control your machine. If you're writing for giving away to other people, I'd use /bin/sh or bash. /bin/sh though simple, is always available. bash is open source, so almost always available, is old enough to be everywhere, but new enough to have some new features. Csh is not available everywhere, and neither is zsh.

share|improve this answer
add comment

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.