ECN No Name Newsletter: September, 1991

The ECN No Name Newsletter is no longer being published. This is an archived issue.

[previous article] [next article]

Shell Configuration Files

Ellen Spoonamore

Have you ever wondered what shell configuration files are? They are files that are used by the *shell*. Every time you log on to your account you run a shell, whether it be Bourne shell (/bin/sh), C-shell (/bin/csh), bash (/usr/unsup/bash), or KornShell (/usr/unsup/ksh).

What is a shell? A shell is a program that interprets your typed commands and their arguments then executes them. When you log on, at least one of these files is read by your shell and used to customize and configure your account. Inside these files are listed UNIX commands that the shell reads and executes, just as if you typed them at the prompt. Some things that you normally do in these files are:

        set your terminal type
        set your path
        set your backspace character
        set defaults    (i.e. default printer)
        personalize your prompt
        run other programs   (i.e. one that informs of new mail)

Which file is used by what shell? .br Basically, you have two types of files: `resource' files, and `login' files. `resource' have file names ending in `rc'. For example if you are running C-shell, then the resource file is called cshrc. Resource files are read anytime a shell is created (ie: logging-in, shell-escape, rcp). Therefore, these files should not contain any commands that produce output onto the terminal screen because, if you run a job in the background, you may not be connected to a terminal, and the shell will fail and exit.

`login' files are read when a user logs into an account. This is useful because you can place machine-specific commands into these files and be assured that they will only run when when you log into THAT particular account.

Files By Category

File name:      Type:        Shell(s) that uses them:

 .profile       login           /bin/sh
                                /usr/unsup/bash
                                /usr/unsup/ksh
 .login         login           /bin/csh
 .cshrc         resource        /bin/csh

As you can see, your .profile is used by several different shells. These shells all look for a file that is named .profile, but they are not necessarily 100% compatible because each understands different variations of the same language. There is not a Bourne-shell resource file. Bourne shell only looks for a file named .profile.

 .profile

stty erase ^H              # set erase to the backspace key
stty kill ^U               # set kill to cntrl-U
stty intr ^?               # set interrupt to cntrl-?
PATH=.:/etc:/usr/local:    #set your path
 :/usr/ucb:/bin:/usr/bin;
export PATH                #marks PATH to be
                           exported to the environment

When you log on and are using C-shell, it looks for two files, .login and .cshrc. The .login file is only read when you first login; whereas, the .cshrc is read whenever a shell is created. Therefore, you should follow the following rule-of-thumb when creating your .login and .cshrc:

  - Put aliases in your .cshrc
  - Put only NON-output creating commands in your .cshrc
  - Do NOT attempt to change the tty in your .cshrc
      because as with the rcp command, you don't HAVE a tty!
  - Put *everything* else into your .login

 .login

set ignoreeof               # Ignore ^D - type 'logout' to logout
set noclobber               # Avoid accidental overwriting files
set notify                  # Notify as soon as job is done
set history = 50            # Remember previous 50 commands
set savehist = 50           # Remember previous 50 commands
                              after logout
set filec                   # Turn file completion on
set fignore = (.o .out)     # Ignore files with .o & .out
                            # when using file completion
set prompt "$cwd  > "       # set your prompt

# Environment variables
setenv PRINTER msd          # use printer in MSEE 189

# Misc commands


webmaster@ecn.purdue.edu
Last modified: Thursday, 23-Oct-97 18:35:48 EST

[HTML Check] HTML