Changing the PATH
for all users

 General Information

Introduction

There are many occasions where you want to change environment variables for all users. Basically there are tweo ways of doing so: You can change the .profile, .cshrc and .login files for every user, or you can change these variables globally for all users. Here we will discuss the second method. In this example we want to add /usr/freeware/bin to the PATH variable for all users. Actually this case is very common, because when you install the freeware from freeware.sgi.com, all packages will be installed to this path.

Changing Variables for all users

There are two files that need to be modified: /etc/cshrc and /etc/profile, they are both executed for all users at login. The changes for each file are written in bold letters. Note that this is also the right place for other changes to the environment. But do not forget the export statement, or your changes will only affect the script /etc/profile itself, rather than the whole session.

Changing /etc/profile

#
# /etc/profile - Default settings for all sh users
#
# This script is executed before $HOME/.profile when an
# sh user logs in or invokes /bin/su with the `-' option.
#

# Ignore keyboard interrupts.
trap ""  2 3

case "$0" in
*su )
    # Special processing for ``su -'' could go here.
    ;;
-* )
    if [ -z "$ENVONLY" ]
    then
        # This is a first time login.
        #
        # Allow the user to break the MOTD only
        trap "trap '' 2"  2
        cat -s /etc/motd
        trap "" 2

        # Check for mail.
        if /bin/mail -e
        then
            echo "you have mail"
        fi
    fi
    ;;
esac

MSGVERB=text:action
NOMSGLABEL=1
NOMSGSEVERITY=1
export MSGVERB NOMSGLABEL NOMSGSEVERITY

if [$LOGNAME = root]
then
    PATH=$PATH:/usr/freeware/bin
else
    PATH=$PATH/usr/gnu/bin:/usr/freeware/bin:
fi

MANPATH=/usr/share/catman:/usr/share/man:/usr/catman:/usr/man:
/usr/freeware/catman
export PATH MANPATH

trap  2 3

Changing /etc/cshrc

#
# /etc/cshrc - Default settings for all csh users
#
# This is 'sourced' before $HOME/.cshrc, which in turn preceeds 
# $HOME/.login when a csh user logs in or invokes /bin/su with 
# the `-' option. 
# Tell the shell where to look for mail.
if ($?MAIL == 0) setenv MAIL /usr/mail/$USER
set mail=$MAIL

if (! $?ENVONLY) then
    # Print the message of the day.
    cat -s /etc/motd
	
    # Check for mail.
    if ( -e /bin/mail ) then
        if ( { /bin/mail -e } ) then
            echo 'You have mail.'
        endif
    endif
endif

setenv MSGVERB text:action
setenv NOMSGLABEL 1
setenv NOMSGSEVERITY 1

if ($USER == "root") then
    setenv PATH ${PATH}:/usr/freeware/bin
else
    setenv PATH $PATH/usr/gnu/bin:/usr/freeware/bin:
endif

setenv MANPATH /usr/share/catman:/usr/share/man:/usr/catman:/usr/man:
/usr/freeware/catman
 Links
  • none