Unix Concepts   «Prev 

Function of .login and .cshrc files in Unix

.cshrc is read every time you log in, but that is not quite true.
The .cshrc file is read every time you start another C shell. The two situations are often the same, but sometimes they are not. For example, suppose you are working in a graphical user interface (GUI). Typical UNIX GUIs let you work in multiple terminal windows.
If we assume your account uses the C shell, then every time you open a terminal window, you’d be starting another C shell. Along with the .cshrc file, the C shell uses another configuration file called .login. Unlike .cshrc, the .login file is read only once per session, when you log in. The .login file is where you define general account features such as initializing your terminal or setting environment variables.
Here is another tip. You do not really need to log out and log in again to process the commands in .cshrc. To read your .cshrc file immediately, use the source command:
% source .cshrc

This command tells the shell to read your .cshrc and immediately run the commands it contains.

csh /etc/csh.cshrc, followed by /etc/csh.login, /etc/.login, /etc/login.std, or
/etc/cshrc, depending on the operating system 
After that, ~/.cshrc and ~/.login

Example

1 $ pathname=/home/lilliput/jake/.cshrc
2 $ print ${pathname#/home}
/lilliput/jake/.cshrc
  1. The local variable pathname is assigned /home/liliput/jake/.cshrc.
  2. The # removes the smallest leading portion of pathname containing the pattern /home; that is, /home is stripped from the beginning of the path variable.