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.

  • There's no "official" shell, but some are better than others. – Emil Mar 21 '12 at 3:05
  • In general, when trying to learn something -- don't hesitate thinking what is best to learn, what is the best way to learn it, etc. -- just do it (be active) and very soon it will become (a lot more) clear what to do and how to do it. – Emanuel Berg Aug 10 '12 at 11:57
  • Learn a Bourne shell lookalike, either bash(1) or dash(1) should do. Something around 99.56% [yes, I just made that up, but it can't be too far from the truth] of shell scripts are written in the venerable sh(1) language, it is somewhat of a lingua franca. More se as the POSIX standard specifies that as the shell that must be available. – vonbrand Jan 23 '13 at 3:48

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.

  • How does these bash differ interactively? I understand that they are not same same for scripting, but for common use? – user1115057 Mar 21 '12 at 13:08
  • Does it mean that under FreeBSD and Debian, tcsh / dash is used for script by the system, and user and root use csh / bash for interactively? – user1115057 Mar 21 '12 at 16:54
  • How does bash differ from what? The only real way to answer that is to read the documentation for each shell; I can't do justice to them in a comment. – Keith Thompson Mar 21 '12 at 17:10
  • 1
    "Does it mean that ...?" -- Not necessarily. For Debian, I think system scripts are typically written using sh or bash; for FreeBSD, I don't know. But as long as those scripts work correctly, there's no real need for you to care how they're written (unless you're changing them yourself). For Debian, root's interactive shell is bash by default; I don't know what it is for FreeBSD, but if you have access to a system you can grep root /etc/passwd to find out. Each user uses whatever shell he or she prefers, using chsh if necessary to change it. – Keith Thompson Mar 21 '12 at 17:14
  • 1
    @EmanuelBerg: The C shell is called that because its syntax is similar to C -- but it's not really all that close. I find bash to be more consistent and powerful. – Keith Thompson Aug 10 '12 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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