Shell – Which shell should I learn for FreeBSD and Debian

debianfreebsdshell

I have read many articles that say the official shell in FreeBSD is tcsh, and in Debian, its dash. However, when I either echo $shell (FreeBSD) or env in Debian, it says that the shell is csh in the first case, or bash in Debian.

This is in fresh installations. I tested under the root account and a normal user account. Also, when I create a new account in FreeBSD, I have the choice of 3 shells; sh, csh or tcsh. If I make no choice, csh is the default for the account.

What is the official, standard shell under those systems? Is it tcsh or csh in FreeBSD? Is it dash or bash in Debian?

Is it me that does something wrong? Or are the articles and sites misinformed?

I want to learn two shells: one for Debian and one for FreeBSD, but I can't find which one I should learn, since its not clear which one is the official shell.

Also, while searching for which shell I should learn, I found this: http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
Is it someone that just doesn't like csh, or should we really avoid csh?

I'm using the latest Debian and FreeBSD versions.

I start to get lost with all these shell options, they all look the same to me (except for the syntax; I mean they all look to offer the same possibilities). It's why i want to learn the official one.

Best Answer

There is no need at all for you to use the default shell for a given system. Both Debian and FreeBSD provide a number of different shells, and most or all of them are available on both, either preinstalled or easily installable.

Watch out for naming. It's not uncommon for /bin/csh to really be tcsh, or for /bin/sh to be bash or ksh.

sh, the Bourne shell, is the oldest Unix shell that's still in common use. bash is probably the most widely used sh derivative; ksh and zsh are also widespread.

csh, the C shell, was developed for BSD by Bill Joy. It has some features that make for more convenient interactive use than sh (or at least than the old version of sh that existed at the time). tcsh is derived from csh, and adds a lot of new features, most of them aimed at interactive use. As you've seen by reading csh.whynot, csh and tcsh have some problems when it comes to using them for scripting as opposed to interactively.

Personally, I started with csh, then switched to tcsh when it became available. I now rarely use csh for scripting, preferring sh or bash (or Perl for anything reasonably complex).

(Update, a few years later: I've since abandoned tcsh, and I now use bash interactively.)

My advice would be to pick a single shell and learn it well, using it on both FreeBSD and Debian. If you choose tcsh, I think you'll have to install it on Debian: sudo apt-get install tcsh. If you choose bash, I don't know whether it's preinstalled on FreeBSD; if it isn't, it should be equally straightforward to install it.

It's not necessary to use the same shell interactively and for scripting, but it can avoid some confusion and make for a shorter learning curve.

ksh is probably about as powerful as bash, and zsh is even more powerful (and has a lot of features I've never taken the time to learn).

I suggest bash, for both FreeBSD and Debian (and for any other Unix-like systems you might use), and for both interactive use and scripting. But other choices are perfectly legitimate, and some might suit you better.

Related Question