9
votes

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.

8 Answers 8

17
votes

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).

6
  • Most scripts are generally written to be sh compliant, since launching a script via sh is usually much faster than bash.
    – Mikeage
    May 7, 2009 at 11:01
  • How's that? On Linux /bin/sh is symlink to /bin/bash.
    – vartec
    May 7, 2009 at 11:03
  • 2
    /bin/sh is not always a symlink to /bin/bash May 7, 2009 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. May 8, 2009 at 2:44
  • On Debian you can use 'dash' as substitute for '/bin/sh'.
    – drybjed
    Jun 2, 2009 at 8:24
9
votes

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.

2
votes

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.

2
votes

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.

1
vote

Don't forget your other question 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.

1
vote

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.

;-)

0
votes

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.

0
votes

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .