Some Unix pointers

Written by Scott.

This document is a short collection of Unix commands and tips collected through the process of helping students to complete the CS164 projects.

Contents:

Setting the path

The path is a list of directories that are searched for programs. To run a program, it needs to be in one of the directories on the path (unless you name its location explicitly).

Typically, you just want to add a single directory to your existing path. You do this like so (throughout this document, I'll use the shell prompt ('%') to indicate things that you type; don't type the prompt character itself):

  % set path = ( $path ~cs164/bin )
This adds one new directory (~cs164/bin in this case) to your existing path directories ($path).

If you want to see your current path, do

  % echo $path

Setting environment variables

Environment variables are pairs of (name,value) associated with every process. Typically, they store certain system-wide configuration information, such as who you are ($USER), where your home directory is ($HOME), etc. You can see all your environment variables:

  % printenv

To set a new environment variable, for example to set MASTERDIR to the value ~cs164, you would do:

  % setenv MASTERDIR ~cs164

To see just the value of one variable, use the '$' metacharacter:

  % echo $MASTERDIR

Making shell settings persist across login/logout

The settings above (path and environment) go away when you exit the shell. To make them persist across logout and login, you need to add the relevant commands to your .cshrc ("see-shark") file, which is in your home directory.

For example:

  % cd             // go to home directory
  % pico .cshrc    // edit your .cshrc file

Then in the .cshrc, you might add lines near the top saying

  set path = ( $path ~cs164/bin )
  setenv MASTERDIR ~cs164
(Then use ctrl-O to save, and ctrl-X to exit.)

Since the .cshrc file is read and executed every time the shell starts, any settings you put here will take effect every time you log in. If you want new settings to take effect immediately, do:

  % source .cshrc

(Note that you will not see the .cshrc file when you do ls, because by default ls does not list files that start with the '.' character. If you type ls -a you will see it.)

Setting up email forwarding

When you get class accounts, it's a hassle to remember to check the email in those accounts, in addition to your regular email (if you have one). So, the usual solution is to setup email forwarding, which is done simply by creating a file called .forward in your home directory.

The .forward simply lists, one per line, the addresses to which you want any email forwarded. As a simple example, you can create the .forward file and specify its contents like so:

  % cd            // go to home dir
  % echo "me@someplace.else.org" > .forward

See "man forward" for more information.

Where to get more help


 
Back to CS164 home page