System Login Scripts


The system maintained login scripts are located in the directory /bham/common/system/login, these scripts are provided as the recomended method to configure your environment. There are also a number of extra scripts which reside in the directory /bham/common/system/setup, these allow support for additional packages such as the SPARCWorks compilers or Poplog.

This document contains the following sections:

Example copies of user files may be found in the directory /bham/common/system/templates.

Functional Overview

The following provides a brief description of the function of each of the login scripts:-

cshrc - This is the csh (or tcsh) startup file, it should be called from within your $HOME/.cshrc, and will then be sourced whenever a new shell is started. Its purpose is to set various shell related variables as well as to define aliases. See csh(1) for futher details on shell variables.

login - This script should be called from within your $HOME/.login, which is processed by login shells after the cshrc has been processed. Its purpose is to configure your environment via a number of variables and to start up the X window system if necessary. Any environment variables set at this point will be propagated to new subshells. For example the $PATH variable is set here, this allows the list of directories that are to be searched when looking for commands to be inherited by all subshells, without the need to explicitly set it in the cshrc file.

rshrc - This is the remote shell (rsh) startup file, its purpose is to perform the configuration of a shell started on a remote machine, as these can not inherit variables from the initiating shell. Its function is a mixture of that performed by the cshrc and login scripts.

xlogin - This script similar to the login script except that it is only concerned with configuring the parts of your environment relating to the X window system.

set-paths - This script sets the PATH environment variable to the default setting, which ensures you have the necessary directories on your search path. These are dependent on the machine you have logged in on. It is called mainly from the login script but is also called from the rshrc script in order to configure the paths for remote shells created by the rsh command.

xstart - This script should be called at the end of your $HOME/.login file and attempts to start a session running under the X window system. The process involved in starting a X session is rather complex, the xstart script is the approved technique for performing this task. Attempts to start an X session by any other means will be unsupported and may result in strange side effects.

xinitrc - This file is used in conjunction with xstart and is used to start an X server on a workstation when logging in from the console.

xmain - The purpose of this script is two fold. Firstly is creates a Main xterm window containing a login shell. Being a login shell your $HOME/.login file will be processed, which in turn will call xstart this will cause the X window clients to be started.
The second purpose of xmain is to hold the X window session together via an exit button. Once the xmain script terminates the X window session will shutdown.
If you have a $HOME/.xmain file this file will be used in preference to /bham/common/system/login/xmain.

xclients - This script contains any X window clients such as window managers, additional xterm windows, clocks etc. which are started by default when you login.
If you have a $HOME/.xclients file this file will be used in preference to /bham/common/system/login/xclients.

Script Interaction

The following diagrams attempt to illustrate the order in which the login scripts are processed for various login methods. Unless otherwise specified scripts reside in /bham/common/system/login.

Console Login Xdm Login




Remote Shell Subshell

Customizing Your Environment

This section aims to give you some hints when you wish to modify your personal login scripts to customize your environment.

Adding extra directories to your search path.
The default path is set in the /bham/common/system/login/login script via the set-paths script, if you wish to add extra directories to this you should place an entry in your $HOME/.login file.

For example, suppose you wish to add your own ~/bin directory to the default path, you could add the following line to your $HOME/.login file:

	set path = ( ~/bin $path )

This will prefix the existing search path variable with ~/bin.

Adding support for packages.
The default copy of your $HOME/.login contains several lines which when uncommented will provide support for some of the most frequently used packages. The comment character is #. Removing this from the beginning of the appropriate line will enable support for the package when you next log in.

X Resources.
The system X resources are contained in /bham/common/system/login/Xdefaults this is always loaded by default. If you have a $HOME/.Xdefaults file then this is merged in after the system defaults are loaded. In some cases users may prefer to not use the system defaults file and to use only their $HOME/.Xdefaults file. To achieve this add the following line to your $HOME/.xmain file before the xterm -ls command:

	xrdb -load $HOME/.Xdefaults

Customisation Guidelines

When tailoring your login scripts, try to adhere to the following guidelines:

  • Only alter path settings in .login - and don't forget to add the existing $path to the new elements,
  • New environment variables should only be added (using setenv) to .login,
  • New command aliases should only be added (using alias) to .cshrc - and remember to use single quotes on the aliases to prevent incorrect variable expansion before .login is consulted,
  • Try to use resource settings in .Xdefaults (or application specific resource files) in preference to command line switches,
  • Try to avoid having a tailored .xmain, but if you really must alter things related to the while X session - for example, merging further X resources - then this is where you should do it,
  • If you change your login scripts and find you can no longer log in, type your username and password but hit F1 instead of RETURN on any machine to initiate a fail-safe login. This will give you a single window for you to rectify the mistake,
  • Don't start excessive numbers of xterms or other clients - they waste precious machine resources!
  • Don't start any gratuitous or unessential programs that waste either network bandwidth or CPU time (eg: xdaliclock) during login - they may be alright on workstations, but not X terminals operating on a remote server!
  • The .xmain and .xclients scripts should be executable otherwise login may fail ("chmod 755 ~/.xclients ~/.xmain" if they aren't),
  • Software installers should make use of the package mechanism to make program suites more easily accessible to other users.