Where to set environment variables

Richard M. Barry R.Barry at sstl.co.uk
Wed Oct 20 14:41:20 UTC 2004


I'm guessing that:
The code in the if-statement (in your /etc/ executes the  /etc/bash.bashrc script, and $PATH gets set in there (ie reset from what you just set it).  Try moving the "PATH=" statement to after the if (just before the export PATH statement), and add ":$PATH" to the end of it (or else you'll again reset $PATH after /etc/bash.bashrc executed). 
 
I hope that made sense.

-----Original Message-----
From: ubuntu-users-bounces at lists.ubuntu.com [mailto:ubuntu-users-bounces at lists.ubuntu.com]On Behalf Of Bastian Doetsch
Sent: 20 October 2004 14:59
To: ubuntu-users at lists.ubuntu.com
Subject: Re: Where to set environment variables


Am Mittwoch, den 20.10.2004, 13:49 +0100 schrieb Jan Kokoska: 

On Wed, 2004-10-20 at 13:30 +0100, Darren Wheatley wrote:

> Hi,

> 

> Can anyone tell me definitively where to put environment settings please?

> 

> I have installed the j2sdk from Sun, but need to alter my PATH to point 

> to it.

> 

> I have tried adding the following to ~/.gcprofile, ~/.bash_profile, and 

> ~/.bashrc but nothing seems to set my path properly:

> 

>     export PATH=$PATH:/usr/local/java/bin

> 

> I need to be able to set environment variables for both shell users and 

> server processes. Again, I tried /etc/profile for server environment 

> variables but that didn't work either.



/etc/profile typically sets PATH system-wide (to be overriden in

~/.bash_profile), so please use that. You should already have the

variable set there (and exported at the end of file) so just add to it

your java path. 




Got the same problem here. Following, you can see my /etc/profile:


root at basti:/home/bdoetsch #   more /etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))

# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).



JAVA_HOME="/opt/jdk1.5.0"



PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/bin/X11:/usr/games:$JAVA_HOME:$JAVA_HOME/bin"



if [ "$PS1" ]; then

  if [ "$BASH" ]; then

    PS1='\u@\h:\w\$ '

    if [ -f /etc/bash.bashrc ]; then

        . /etc/bash.bashrc

    fi

  else

    if [ "`id -u`" -eq 0 ]; then

      PS1='# '

    else

      PS1='$ '

    fi

  fi

fi



export JAVA_HOME

export PATH



umask 022


and here's the result when I type echo $PATH:


bdoetsch at basti:~ $ echo $PATH

/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/games


So where's the error?
Thanks,
Bastian




Jan






-- 



"The path of excess leads to the palace of wisdom."

- William Blake, The marriage of heaven and hell

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20041020/3429f090/attachment.html>


More information about the ubuntu-users mailing list