Next | Prev | Up | Top | Contents | Index

Bourne and Korn Shell Configuration Files

When a Bourne or Korn shell user logs in to the system, two startup files are executed in the following order:

  1. The /etc/profile file.

    This is an ASCII text file that contains commands and shell procedures and sets environment variables that are appropriate for all users on the system. This file is executed by the login process.

    A sample /etc/profile is shown below:

    # Ignore keyboard interrupts.

    trap "" 2 3

    # Set the umask so that newly created files and directories will be readable

    # by others, but writable only by the user.

    umask 022

    case "$0" in

    *su )

    # Special processing for ''su -'' could go here.

    ;;

    -* )

    # This is a first time login.

    #

    # Allow the user to break the Message-Of-The-Day only.

    trap "trap '' 2" 2

    cat -s /etc/motd

    trap "" 2

    # Check for mail.

    if /bin/mail -e

    then

    echo "you have mail"

    fi

    ;;

    esac

    trap 2 3

    In the example, several commands are executed:

  2. The individual user's .profile.

    This file is similar to /etc/profile, but is kept in the user's home directory. The .profile file can contain additional commands and variables that further customize a user's environment. It is executed whenever a user spawns a subshell.

    A sample .profile is shown below:

    # Set the interrupt character to <Ctrl-C> and do clean backspacing.

    stty intr '' echoe

    # Set the TERM environment variable

    eval 'tset -s -Q'

    # List files in columns if standard out is a terminal.

    ls() { if [ -t ]; then /bin/ls -C $*; else /bin/ls $*; fi }

    PATH=:/bin:/usr/bin:/usr/sbin:/usr/bsd:$HOME/bin:.

    EDITOR=/usr/bin/vi

    PS1="IRIX> "

    export EDITOR PATH PS1

    In this example:

For information on the shell programming commands used in these examples, see the ksh(1) and sh(1)reference pages.


Next | Prev | Up | Top | Contents | Index