Which shell should I learn for FreeBSD and Debian?

6,144

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.

Share:
6,144

Related videos on Youtube

user1115057
Author by

user1115057

Im interested in learning how to do low level stuff like kernel, os, driver.... Thing i need to learn: Programming (i already know how to write in C, C++, but i still need to think like a programmer...).

Updated on September 18, 2022

Comments

  • user1115057
    user1115057 over 1 year

    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.

    • Emil
      Emil about 12 years
      There's no "official" shell, but some are better than others.
    • vonbrand
      vonbrand over 11 years
      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.
  • user1115057
    user1115057 about 12 years
    How does these bash differ interactively? I understand that they are not same same for scripting, but for common use?
  • user1115057
    user1115057 about 12 years
    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?
  • Keith Thompson
    Keith Thompson about 12 years
    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
    Keith Thompson about 12 years
    "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.
  • Emanuel Berg
    Emanuel Berg over 11 years
    Yes, if you use Debian it would be a good piece of advice to use sh or bash as you probably soon will like to do configuration, and, if you've been using those shells, the system scripts will not be that alien. @KeithThompson: The C shell - is it called that way because the syntax is the same as in the programming language? I ask this because I'm so much more fluent in C than in the strange bash syntax.
  • Keith Thompson
    Keith Thompson over 11 years
    @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.