Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Of the major Unix shells (bash, ksh, tcsh, zsh, others?), are there any compelling reasons to use one over another?

  • Which is the most interactive/command-line friendly?
  • Which is the most conducive/intuitive for writing scripts?
  • Are there any major built-in features that one shell offers that others don't?
  • Are any of these shells really good for one type of function, but not another? Or are they all pretty well-rounded/flexible?
  • Is it just a matter of personal preference?

I can make this community wiki if anyone prefers.

share

locked by HopelessN00b Dec 5 at 7:38

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

8 Answers 8

up vote 17 down vote accepted

Current:

  • bash — Bourne again shell, default shell in most Linux distributions. Decent features;
  • zsh — the most feature rich, but still rarely used;
  • ksh — default shell in Solaris, AIX and other few other unices;
  • tcsh — default shell in various *BSD flavor unices;

Historic:

  • sh — original Bourne shell (released 1977). Obsoleted by bash;
  • csh — original C shell (released 1978). Obsoleted by tcsh and ksh;

Note, that bash, ksh and zsh derive from sh syntax, while tcsh derives from csh syntax. This are two quite different syntaxes.

The feature chart (wiki).

share
    
Most scripts are generally written to be sh compliant, since launching a script via sh is usually much faster than bash. –  Mikeage May 7 '09 at 11:01
    
How's that? On Linux /bin/sh is symlink to /bin/bash. –  vartec May 7 '09 at 11:03
2  
/bin/sh is not always a symlink to /bin/bash –  Brad Gilbert May 7 '09 at 20:03
1  
When you instantiate bash as "sh", it runs in an "sh" mode that supports a subset of bash commands. I believe that "sh" syntax is a POSIX standard. –  duffbeer703 May 8 '09 at 2:44
    
On Debian you can use 'dash' as substitute for '/bin/sh'. –  drybjed Jun 2 '09 at 8:24

fish is a new shell that is perhaps more interesting than the others, not because it necessarily has more features, but because they Just Work by default and because fish strives for usability.

A few screenshots (1, 2, 3, 4) are enough to give the general idea.

fish is now the default shell on my Mac at work. Go figure.

share

If you're going to learn a shell other than sh/bash, you might as well just go with zsh. I don't think anyone seriously contests that it's the most powerful and feature-packed of the alternative shells; whether it's just bloat is, of course, still up for debate.

I've heard good things about fish, but never worked up the effort to bother with them.

The admins I know consider csh and tcsh to be abominations that should be avoided at all costs, and I agree with them despite never having been forced to put myself through either shell.

share

I would recommend knowing bash well as it is one of the most common (generally the Linux default). Personally, I love zsh as my interactive shell. It has great completion features. For example, you can set a list of hosts and when you do something like ssh Ser[tab] it will know to try to tab auto complete one of those hosts. It also has recursive globing, so if you want to find all jpeg files in the current and subdirectory you can use ls -ld **/*.jpg . There are lots of fun features with zsh (search for people's .zshrc files), and you can set it to 'bash compatible', so it is easy to switch between the two. If you combine this with GNU Screen you might find the command line becomes quite a pleasure to work with.

share

Don't forget your other question http://serverfault.com/questions/5632/most-common-unix-linux-shell - the most popular shell is probably most popular for a reason ;-)

For what it's worth, most people don't switch off between shells frequently so it'll be hard to get a well-rounded comparison of the various options; you'll be more likely to see different people espousing the virtues of their favorite shells. From what little I've heard about different shells, they all offer some of the same basic features (like I/O redirection, command history, etc.) so personal preference is likely to be a large component.

share

A compelling reason to use ZSH that has not been mentioned is vi mode and emacs mode.

For those who love to use their vi muscle memory in the shell, this is a killer feature.

And for those who prefer emacs, you can use those keybindings too, but true emacs-believers would probably say that emacs is their favorite shell.

;-)

share

Preference for day to day use is really a mather of personal taste, however, when writing scripts, I try to be posix compliant for portabilities sake.

share

Just as Heads Up: Ubuntu defaults "sh" to "dash" which lead to some problems in the past with POSIX compability. Apparently, the echo commands differ slightly.

share

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