Managing your .cshrc & .login files

If the UNIX system seems complicated and unfriendly to you, you may not be taking advantage to several of the most useful features of the operating system - you haven't customized your environment to your own needs. These notes will help you get started with making adjustments to your UNIX environment, but we can't document everything. I suggest that you find a good book on UNIX when you are getting started. If you think about it, you may be spending hours in front of the workstation, the more proficient you become with the operating, the quicker you can get your work done. A reference book is not a bad investment. "UNIX in a Nutshell", by O'Reilly and Assiciates, Inc. is a handy reference book when you work with UNIX, but most of the same information is contained in the online documentation. I use the c-shell, and one good reference to that shell is "The UNIX C Shell Field Guide", by Anderson and Anderson.

When you log into the UNIX system, commands contained in two of your files are executed, first the .cshrc file is parsed and some important parameters are set, then you .login file is executed. To customize your environment you make changes to these files. For example, you can select whether you want to use the "delete" or "backspace" key to erase the last character, set the length of command history that the system tracks for you, add shortcuts for frequently used commands, etc.. In addition, several important "environment" variables that affect the way you move about the file system, access programs and online documentation, etc. are defined and set in these files. If these parameters are set incorrectly you may not be able to access the programs and directories that you need.

Here are several important variables that you should customize to suit your needs:

Variable Explanation
path when you execute a command in UNIX, a series of locations are searched to find the executable file that performs the command. You specify where to look using the path command. If you don't have this parameter set correctly UNIX won't find the command that you want. Typical customizations include adding your own "bin" directory into the list so that your own program are run without typing the complete path names. The paths in this list are searched sequentially, so if two directories have executable programs or scripts with the same names, the first one encountered is the one you'll get.
cdpath If you're tired of typing in long pathnames add a frequently accessed directory to your cdpath variable. Then you don't have to type anything but the name of the subdirectory that you want to move to. For example if I add "/terra/ammon" to my cdpath then I can "cd" to the directory called "/terra/ammon/Arabia" by simply executing the command: "cd Arabia".
MANPATH MANPATH is a variable that contains the locations of the manual pages (online documentation) associated with the different packages on the UNIX system. Some of the most important locations are listed in the next section.

MANPATH

Please note that you should use "man -F" in place of "man" on our system (make an alias, see the example below). If you use this list of paths, you will find the most commonly accessed documentation.







/usr/man:/usr/local/man:/usr/X11R6/man:/usr/X11R5/man:/usr/share/man:
/opt/SUNWspro/man:/opt/FSFg77/man:/opt/FSFgcc/man:/opt/FSFlibg++/man:
/usr/local/teTeX/man:/usr/local/ncarg/man:/usr/local/gmt/man:/met/man:/met/ldm/man

The manual pages for Computer Programs in Seismology are located in the following directories:







/slu/PROGRAMS/VOLI/MAN /slu/PROGRAMS/VOLII/MAN /slu/PROGRAMS/VOLIII/MAN /slu/PROGRAMS/VOLIV/MAN /slu/PROGRAMS/VOLV/MAN /slu/PROGRAMS/VOLVI/MAN /slu/PROGRAMS/VOLVII/MAN /slu/PROGRAMS/VOLVIII/MAN /slu/PROGRAMS/CALPLOT/MAN









A Sample .cshrc file:

You can find valuable, detailed discussions of .cshrc and .login files in a any good UNIX reference book so I'll present a commented example and leave it to you to find detailed explanations in more comprehensive references. The important thing for us to know where certain tools like compilers and other programs are located on our system. To keep this short, I'll simply present an example .cshrc file. You should study the manual page on "csh" to see what many of these parameters are and do - the sooner you study that material, the quicker you'll be using the short cuts that make UNIX a valuable operating system. Since the file contains some non-printing characters, it's safer for you to download the file directly to disk than to copy and paste from this page. You can download this sample .cshrc file by clicking here (actually, click and hold the link and choose to save the file, it will be called sample.cshrc).




# Ammon's Sample .cshrc file
#
# add directories for local commands
#
# I use the openwindows environment, so here is where to find it
#
set lpath = ( /usr/openwin/bin/xview /usr/openwin/bin )
#
#  These are some paths needed for our site
#
# The "\" symbol means that a command is continued on the next line
#
set slupath = ( /slu/bin \
                       /opt/SUNWspro/bin \
                       /opt/FSFgcc/bin \
                       /slu/sac/bin \
                       /usr/local/gmt3.3/bin \
                       /usr/local/java/bin \
                       /usr/local/itcl/bin \
                       /usr/local/Acrobat3 \
                       /usr/local/X11R6/bin \
                       /usr/local/netpbm \
                       /usr/local/teTeX/bin \
                       /usr/local/latex2html \
                       )
#
if ($?prompt) then
         
set path=( ./ \
        ~/bin \
        /usr/ccs/bin \
        /usr/ucb \
        /bin \
        /usr/ucb \
        /usr/local \
        /usr/local/bin \
        $lpath \
        /usr/bin   \
        /usr/bin/X11 \
        /local/bin \
        $slupath )
#
# The "cdpath" contains directories your frequently visit - customize it for your account
#
   set cdpath = (.. ~ ~/bin ~/Programs ~/Research /terra/ammon /geo /geo/GeoData)
#
#  MANPATH set up
# 
set M01  = ( /usr/man:/usr/local/man:/usr/share/man:/usr/X11R6/man:/usr/X11R5/man )
set M02  = ( /opt/SUNWspro/man:/opt/FSFg77/man:/opt/FSFgcc/man:/opt/FSFlibg++/man )
set M03  = ( /usr/local/teTeX/man:/usr/local/ncarg/man:/usr/local/GMT3.3.1/man:/met/man:/met/ldm/man )
set MPTH = ( $M01":"$M02":"$M03 )
#
setenv MANPATH "$MPTH"
#
unset M01
unset M02
unset M03
#
# history is a useful UNIX utility for re-executing commands
#
set history=50
set savehist=50
#
set mail=/usr/spool/mail/ammon
set group=(`whoami -g`)
#
# noclobber helps prevent me from overwriting files by accident
#
set noclobber
# the next one turns on file-name completion
set filec
unset noglob 
# this one forbids the creation of large core files when programs crash
limit coredumpsize 0
# this one lets me run large programs
unlimit stacksize
# default file creation permissions
umask 002
# special characters
stty erase '^?'
stty intr '^C'
#
# For the cshell
#
set prompt="`hostname`\!% "
#
endif
#
# I keep most of my aliases in a separate file 
#    and initialize them here
#
source $home/.alias
#
# put the path name in the window title
#
alias settitle 'echo -n "^[]2;$cwd^G"'
settitle
alias cd    'cd \!*;settitle'
#
# This is an important one:
#
alias man 'man -F'
#
#   "less" is like a hybrid of "more" and "vi", I use it because I
#    can back up in man pages using vi-like commands
#
setenv PAGER less
setenv EDITOR vi
setenv PRINTER lj
#
setenv LD_LIBRARY_PATH /opt/SUNWspro/lib:/opt/FSFgcc/lib:/usr/local/lib:/usr/openwin/lib:/usr/X11R6/lib:
#
#   SAC Environment Settings
#
setenv SACDIR /geo/SAC2000
setenv SACLIB $SACDIR/bin/libsac.a
setenv SACAUX $SACDIR/aux
setenv SACGRAPHICSDEVICE X
#
#  GMT Home
#
setenv GMTHOME /usr/local/gmt3.3.1
#
# These are for netscape communicator and are customized for
#  running it on mantle - they should be different on other machines.
#
setenv CLASSPATH /geo/Communicator/java/classes/java40.jar:/geo/JDK/jdk1.1.5/lib/classes.zip
setenv MOZILLA_HOME /geo/Communicator
#
# These are for my own programs, you won't need these but I wanted to point out that
#    you can define your own environment variables
#
setenv PREM_R_GVEL /terra/ammon/NASW/prem.rayl.g
setenv PREM_L_GVEL /terra/ammon/NASW/prem.love.g
setenv SEEDRESP /home/mantle/ammon/Data/IRIS/RESPONSES

Sample .login file

Here is a simple .login file that I use, again, many of these features are user dependent and you must understand what these things do to harvest the value of the customization. You can download this sample .login file by clicking here (it will be called sample.cshrc). See the man pages!




# login startup file for csh
#
setenv SHELL /bin/csh
#
if ($TERM != "sun") then
        set noglob
        set term=`tset -S -Q -mdialup:\?vt100 -mnetwork:\?vt100 -munknown:\?vt100 -mdumb:\?vt100`
        setenv TERM "$term[1]"
#
        if ($TERM == 'xterm')then
                echo "^[]1;`hostname`^G"
        endif
#
#       setenv TERMCAP "$term[2]"
endif
#
#  OPENWINDOWS Set up
#
set mychoice=openwin   #the default
#
if( `tty` != "/dev/console" || $TERM != "sun") then
        setenv SACGRAPHICSDEVICE tek4014
        exit # leave the user at a regular C shell prompt
endif
#
#
if( ${?OPENWINHOME} == 0) then
        setenv OPENWINHOME /usr/openwin
endif
#
#
if (! -e $OPENWINHOME/bin/openwin ) then
        set mychoice=generic_x
endif
#
switch( $mychoice )
case openwin:
        unset mychoice
        echo " "
        echo -n "Starting OpenWindows (type Control-C to interrupt)"
        sleep 5
        setenv FONTPATH $OPENWINHOME/lib/fonts:$OPENWINHOME/lib/fonts/100dpi
        $OPENWINHOME/bin/openwin
        clear_colormap
        clear
        echo " "
        echo -n "automatically Logging out (type Control-C to interrupt)"
        sleep 10
        logout
        breaksw
case generic_x:
        unset mychoice
        echo -n "Starting X (type Control-C to interrupt)"
        sleep 5
        startx
        echo -n "automatically Logging out (type Control-C to interrupt)"
        sleep 10
        logout
        breaksw
endsw

For the advanced user: A useful script to automatically set the display on a remote machine

(Assuming that you are coming onto this machine from only one other window).




set D=`who | grep rbh | head -1 | sed -e '1s/^.*(//' | sed -e  's/).*$// ' `
setenv DISPLAY ${D}:0.0
echo $DISPLAY
unset D


Top | CJA's Guide Index | Ammon's Home | Department of Geosciences
Prepared by: Charles J. Ammon,