Setting up your environment the way you like



Last revision August 9, 2004

Table of Contents:
  1. Shell interpretation
  2. Editing command lines
  3. Stuck in a Unix login session?
  4. Program execution
  5. Simple commands
  6. Unix command syntax
  7. Controlling processes
  8. Your login environment

This discussion applies only to the Berkeley C-shell (or its derivatives, such as tcsh). Other initialization files are used by the Bourne or Korn shells, which are rarely used in Earth Sciences.

The shell has various parameters that can be set by you to control your environment. It is handy to be able to invoke these automatically whenever you log on. It is also handy to execute certain commands, such as checking for system messages, whenever you log on. The shell looks in your home directory for two special files into which you can place commands to be executed when it starts up:

.cshrc
.login

The leading dot is part of the filename in each case.

On Pangea, new accounts are given a .cshrc and .login that each simply reference a system file (/usr/local/bin/.syscshrc and /usr/local/bin/.syslogin, respectively) that does all the standard things. You only need to add new things as you like (such as new aliases). If you remove the references to the system files, then you will miss out on system-wide environment settings that the system manager makes. Something will almost certainly break, or not run, as a result. The only help the system manager will offer in such a case is to tell you to restore the references to the system files.

The .cshrc file in your home directory contains commands to be executed by any C-shell process that you start, whether an interactive login shell, a remote network shell, or a sub-shell (such as a shell script).

The most important thing to do in the .cshrc file is to set the path variable, which tells the shell where to look for programs that you type on the command line. The system standard .cshrc on pangea gives you a path referencing all system directories. You can add a directory of your own by adding a line to the end of your .cshrc with this syntax:

set path = ($path myowndir)

Substitute your desired directory (or list of directories, separated by spaces) for myowndir. On pangea, you should only add to the existing path variable, using this exact syntax. If you set a completely new path, that does not include the existing pre-set directories (the function of the $path in the format above), then don't be surprised if the shell can no longer find programs for you.

You can always list which directories are in your current path with this command:

echo $path

You can ask the shell to locate a program for you, without running it, using the built-in which command. For example, you can see in which directory the shell finds the pine program with this command

which pine

which gives this result on pangea:

/usr/local/bin/pine

The .cshrc file should not have interactive commands like msgs or interactive settings like terminal settings. Some of the programs that you want to run, which are really shell scripts, may be adversely affected by interactive commands in the .cshrc because they also try to execute the commands in this file when they start up.

The .login file in your home directory is executed when an interactive login shell starts up. This is the place to put things like terminal settings, alias settings used in interactive work, mail reading, etc.

<--Previous Overview

Comments or Questions?