Compute Canada

What's with those shells?

Please note: The FAQ pages at the HPCVL website are continuously being revised. Some pages might pertain to an older configuration of the system. Please let us know if you encounter problems or inaccuracies, and we will correct the entries.

When you apply for an account you are presented with the choice between different login shells:

bash ("Bourne again" shell).

csh (C shell)

ksh (Korn shell)

They differ in their "feel" and how they handle system commands. ksh and bash largely understand each other's command syntax. csh is somewhat different.

bash is a "GNU" shell that uses features from the older shells csh and ksh. It is quite popular because it offers many convenient features, such as command and file-name completion by pressing the "Tab"-key. Its scripting syntax is almost identical to the one of ksh, which enables you to use ksh setup files.

Some people find csh best because it is simple and has a syntax that is similar to the C programming language (thus the name). A lot of script files for Unix are written in csh, and it is a good idea to maintain a good setup file for csh, even if csh is not your login shell. This will make your life easier when you are trying to install something or to run shell scripts from third parties.

ksh offers some extended features compared with csh. As an example, you can recall commands that you typed previously. With ksh, this is usually done by pressing the "escape" key, and scrolling through previous commands with arrow keys. However, its syntax is rather different, so that csh commands can usually not be issued to ksh.

Choosing a login shell is largely a matter of taste. However, some programs require a specific shell to run. You can always call a shell by typing "/usr/bin/name_of_shell", where name_of_shell might be csh, tcsh, ksh, bash or sh (the latter is another standard shell that is often used for scripts). Make sure you maintain setup files for the shells you use, even if they are not your login shell.

In scripts, shells are usually called with a "shebang" sequence, that looks like:


in the first line. In such cases, it can happen that environment variables, such as PATH get reset to some default. This is why it is a good idea to start csh scripts with #!/bin/csh -f. The -f option avoids sourcing in the .cshrc file, leading to consistent behaviour of the script for different users (with different .cshrc files).

All shells are documented in the man pages: type "man name_of_shell" to get more information than you'd care to know.