Selecting a Login Shell

Your login shell is the shell that the system starts up for you when you log in. You should determine which shell is your login shell, and change it if it's not the one you want to use. The SHELL environment variable usually contains the pathname of your login shell. You can display its value by using the echo command:

% echo $SHELL

The response from echo should be a pathname such as /bin/sh, /bin/csh, or /bin/ksh. The last part of the path tells you which shell you're using. If the shell you want to use is already your login shell, you're all set.

If you decide to use a different login shell, you need to know where that shell is located. Use the which command to determine the shell's pathname:

% which tcsh
/bin/tcsh

In this example, which indicates that tcsh is installed in /bin/tcsh. (The path might be different on your system.) Once you know the shell's pathname, run your system's "change shell" command (probably chsh or passwd –s). Suppose your current shell is csh but you want to use tcsh and know from using which that its pathname is /bin/tcsh. Make tcsh your login shell like this:

% chsh                           Run the change-shell command
Old shell: /bin/csh              chsh displays your current shell
New shell: /bin/tcsh             Type in the pathname of the shell you want to use

Some versions of chsh display a list of shells from which you can choose. Others need to be invoked this way instead:

% chsh dubois /bin/tcsh

The first argument is your username (the name you use to log in) and the second is the path to the shell you want to use.

Systems based on 4.4BSD use chpass to change the shell:

% chpass -s /bin/tcsh

If your shell-changing command fails, see your system administrator. Otherwise, log in again and you'll be talking to your new shell.

Trying a Shell Temporarily

If you're not sure you want to make a given shell your login shell, you can try it temporarily. Type the shell's name to start it up, issue the commands you wish to execute, then terminate the shell by typing exit. For example, to run a sample session of tcsh, use the following steps:

% tcsh                               Start tcsh
% ...type other commands here...     Run some commands
% exit                               Terminate tcsh and return to your login shell

You'll get an error message if the shell can't be found:

% tcsh
tcsh: Command not found.

In this case, the shell might be unavailable on your machine or installed in a nonstandard location. Check with your system administrator.

A Recommendation: Use tcsh, Not csh

csh is widely available, especially on Berkeley-derived UNIX systems, where it tends to be the standard user shell. csh is usually available on non-Berkeley varieties of UNIX as well, such as those derived from System V. tcsh isn't "officially" supplied by as many vendors as csh, but tcsh runs on many versions of UNIX and is available free over the Internet. If tcsh isn't provided on your system, see Appendix A, Obtaining and Installing tcsh, for instructions on making it available.

I recommend you make tcsh your login shell for daily work. tcsh is more powerful and convenient than csh, and can help you get your work done more effectively. Some of the advantages tcsh offers over csh are:

  • A command-line editor.

  • Better word completion facilities than csh; tcsh can complete command and variable names in addition to filenames and usernames. Also, individual commands can be programmed to complete in specific ways.

  • Spelling correction.

  • Better assistance for entering hard-to-type filenames.

  • rm * detection to help prevent disastrous file removal errors.

  • Better standardization. Vendors often tinker with the version of csh supplied on their systems. This means you may find that csh behavior varies from vendor to vendor. With tcsh, you can put the same version on all your machines.

  • With csh, you generally need to wait for your vendor to get around to fixing bugs. With tcsh, bugs tend to get fixed quickly because there is an easy way to report them and an active tcsh developer's group that addresses them (see Appendix C, Other Sources of Information).

Get Using csh & tcsh now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.