TSRI - IT Services - UNIX - FAQ
FIX UP YOUR HOME
[ TIPS FOR .cshrc]
by Mike Nguyen
Table of Contents
I'm not talking about fixing up your home by getting parts from "Home
Depot" or "Home Base" store, not that kind of home. I will enclose
tips to fix up your home's environment, in other word, your computing environment,
beginning with those start up files in your home's directory. Let's discuss
about the ".cshrc" file
in your home directory.
I will try to avoid being technical like : "The colonel (kernel)
forks a child
(process) already. Because it cannot abort
cleanly, it'll became a zombie.
You have to kill its parent
(process) to get out unless you reboot
the system...".
My goal is to use day-to-day words and very simple examples so that
it is easily understood by everyone, even for readers with little computer
background or with limited English.
* * *
Type of Shells
When you log in to a UNIX system, the system gives you a "shell".
The "shell" is a command
interpreter - it figures out and executes the commands you put together.
You can think of the "shell"
as a layer of software between you and the internal workings of the system.
There are several different shells: Borne shell (sh),
C-shell (csh), Korn shell
(ksh), Tickle shell (tcsh)
... to name a few. Each of them has its own advantage. The C-shell is the
most popular and the most user-friendly. Unless you request otherwise,
you are given a C-shell when your account is opened at TSRI.
The C-shell reads the ".cshrc"
file in your home directory every time you login. The file .cshrc
is an initial setup file for both interactive and non interactive C-Shells.
It's used to set your environment variables to default values. These variables
are used by lots of programs on your system to define certain default operations.
You can customize your computing environment and create your own commands
by setting the values of variables.
Any error or a misconfigured item in your .cshrc
will cause you trouble or hinder the performance of your system.
Here are some common mistakes:
Top...
* * *
PROBLEM: Why is my computer SO SLOW ?
SCENARIO:
user: Why is my computer
is so slow ? When I type a simple command; it takes 30
seconds for the system to come back with the result.
RC: Did you change anything lately ?
user: No.
RC: You have updated your
.cshrc file recently.
user: Oh! My friends are so nice,
they let me use their tools. I put them all in my path.
ROOT CAUSE:
This user added so many friends' home directories in his PATH variable:
---
setenv PATH /home/johndoe/bin
/home/janedoe/local /home/batman/src \
/home/spiderman/tools /nfs/system_name/export/good_stuff \
---
so on ...
EXPLANATION:
Each friend's directory resides on a different system.
There are other applications (NFS, NIS,
automount) running in the background to present these directories
so they appear to be local. But they are not actually. The directories which
are not locally mounted file systems are available to you by
NFS (Network File System). The NFS directories depend on the network
and the source system availability.
Every time this user types a command, his system has to
go around the campus to check one system after another and look into each
friend's directory before executing. This process takes time.
This user also depends on other networks and systems unnecessarily.
If other networks or systems are down; his account will stop working or
will work painfully slow.
Just like before moving into a new home, you have to have
electricity, water, and cable connected. Your .cshrc
file is meant to do the same thing for your computing environment. But
please do not OVERDO it. It is impractical to demand that : I won't move
into the new house until the swimming pool is in place AND the golf course
in my backyard is completely done.
RULE OF THUMB: Keep .cshrc simple. Avoid NFS mount in your PATH.
Top...
* * *
PROBLEM: I cannot read my mail.
SCENARIO:
user: Suddenly, I can
not read my mail any more. When I try, I get a "permission
denied" error.
RC: Have you changed anything lately ?
user: Oh! Only my .cshrc file. I was
having problem running an application and my
UNIX guru friend let me copy his .cshrc file.
ROOT CAUSE:
This user copied his friend's .cshrc
file to use as his own. There is a
variable name MAIL
hard-code for his friend (johndoe) usage only.
---
setenv MAIL /var/mail/johndoe
---
EXPLANATION:
There are basic .cshrc
files which you can copy for your own usage. But if a .cshrc
file had been customized to work for somebody; it is not wise to
blindly copy over and to use it as your own.
This user should compare his friend's .cshrc
file with his own. Then he should add the missing item(s) or should correct
the affected item(s) in his own .cshrc
file or on his system.
Supposed your neighbor is an organized person. He draws
a map of tools placed in his house: hammer is in the garage, knife is in
the kitchen, so on ... You can learn from his idea to be organized, and
create your own map of tools for your house. You should not copy his map
and then following his map to find your tools around your house; because
your tools' location and your neighbor's map are not matched.
RULE OF THUMB: Do not copy someone else .cshrc file unless
you know how to modify it
to your own environment.
Top...
* * *
PROBLEM: My system complains "Undefined variable" after every command.
SCENARIO:
user: Suddenly, my computer
complains about "XXYYZZ - Undefined variable"
after every command I type.
RC: Did you change anything lately ?
user: No.
RC: Let me check. Your
.cshrc file reads other users'
.cshrc files.
user: Oh! I don't know what happened
then. But it worked for me for a long time until now.
ROOT CAUSE:
This user had a .cshrc
file which "read" his friends' .cshrc file.
---
source /home/tomhank/.cshrc
source /home/tomcruise/.cshrc
---
EXPLANATION:
"source" is a
command to read and to execute commands from a configuration file.
Example 1: After you update your .cshrc;
you must log out then log in so that the shell can read the newly updated
.cshrc file. Or in each window,
you use source command to have
the shell read the new .cshrc file:
your_system %
source ~/.cshrc <CR>
There are certain .cshrc files
which you can "read" to update your computing environment. Such as InsightII
application has a step to ask you to "read" its cshrc
-without the dot - file :
---
your_system % source
/usr/msi/cshrc <CR>
---
Example 2. Inside your .cshrc,
you can use source command to read
other configuration files.
Please take extra caution and avoid abusing this practice. Reading
your friend's .cshrc is not a good
idea. If your friend updates his .cshrc;
you will be affected. Or after a period of time, his computing environment
would not be the same as yours any more.
This user should compare his friend's .cshrc
file with his own. Then add the missing item(s) or correct the affected
item(s) in his own .cshrc file
or on his system.
Supposed your neighbor is a nice person, he creates a gate in the fence
between his backyard and yours.
He lets you use the gate and go through his backyard every time you
want to take a shortcut to the park.
But later on, your neighbor changed his backyard usage, i.e. Adding
a shed, planting a tree. The shortcut trail is not available to you any
more.
RULE OF THUMB: Don't read (source) someone else .cshrc .
Top...
* * *
PROBLEM: Every time I login to that computer, it displays 3 "core dump" lines.
SCENARIO:
user: Every time I login
to that particular computer, it spits out a few "core
dump" lines.
RC: Let me check. Your
.cshrc file executes some extra commands.
user: Oh! It worked conveniently
for me until we upgraded that [XYZ] computer.
ROOT CAUSE:
This user put some extra UNIX commands in his .cshrc
file.
EXPLANATION:
In theory, you can put any UNIX command in your .cshrc.
But in real life world you should think
twice before adding anything extra.
All UNIX systems are not created equal. There are many Platforms,
Architectures, and OS
(Operating System) Versions out there. And they create "incompatible"
problem which means
one application that runs on one UNIX system doesn't mean it will run on
another UNIX system.
Platforms Dependents:
UNIX workstations are available from many manufacturers. They are called
PLATFORMS: CRAY, DEC, HP, SGI, SUN, etc... One binary executable application
- for example "netscape" - compiled
on one platform will not run on another platform.
Architectures Dependents:
Each platform has many types of CPUs. They are called ARCHITECTURES.
For example: SGI has R4K, R5K,
R10K,... SUN has sun4c, sun4d,
sun4m, sun4u,... With SUN, they all are "SPARC", use "arch
-k" to be sure SUN's arch. (Equivalent in PC world, you have CPUs:
286, 386, 486, Pentium,...) Programs compiled on one architecture
might or might NOT run on another, depending on what library it used.
OS Versions Dependents:
Each architecture has many Operating System versions for it. HP had
a major OS change between HP-UX 9.X
and HP-UX 10.X. SGI had a major
OS change among IRIX 4.X, IRIX 5.X
and IRIX 6.X. Sun had a major OS
change between SunOS 4.X and Solaris.
(Equivalent in PC world, you have Window
3.X, WIN95, WIN98, ...)
One program compiled on one OS version might or might NOT run on another.
The .cshrc file of this user
is trying to execute some commands tied to a particular Platform / Architecture/OS;
therefore, when that condition is no longer exist, those commands crashed
and generated the "core" dump files.
At TSRI, a lot of users have to login to many different UNIX systems
(CRAY, DEC, HP, SGI, SUN) everyday to have their work done. It's better
to keep .cshrc file "open", not
directly tied to any particular environment.
RULE OF THUMB: Don't put unnecessary extra UNIX commands in
your .cshrc file.
Top...
* * *
MODEL: There is a MODEL .cshrc file with EXPLANATION available for you.
MODEL .cshrc:
This web page shows you a .cshrc file with many explanations embeded in it.
You can read it to see how a .cshrc
works. Or you can save it as a text file, then MODIFY it
to your own environment.
Of course, there are many ways to skin a cat, there are many roads
which leads to Rome, there are many ways to set up your .cshrc file.
This model file is one of the basic. When you get the hang of it; you can create a fancier one,
or a more complicated one later.
cshrc
File With Explanation - The MODEL .cshrc file
Top...
* * *
Any question, bug report or other comment regarding this web page should be directed to
Michael (Mike) Nguyen at x4-9364.
Back
to IT Services-UNIX-FAQ
|