PLease HELP!!! PATH variable issue

Hello,

I logged in to the unix solaris with my user name and then I again logged in with the sudo bash -l command

now when I do echo $PATH

It shows me => /usr/bin:/usr/local/bin:/usr/bin/usr/sbin:/usr/ucb:/usr/local/bin

How do i find out where is this file located for setting the PATH variable...

Also, If i installed jdk and tried setting PATH variable but everytime I logout and log back in I have to set it up again even though I export it ??? Why doesnt it propogate changes to all users or even on my re-login...Also, if i open one more putty window and try doing echo $PATH i dont see the path variable set to what i had set

Here is how I do it =>
JAVA_HOME= /usrJAVA/jdk1.6.0_25
export JAVA_HOME

PATH=$JAVA_HOME/bin:$PATH
export PATH

Environment variables don't work that way, they're not global variables. All export means is that whatever child processes you create will get a copy of it.

When you login, your shell reads and runs lines from /etc/profile to set up environment variables and things, then maybe ~/.profile or something like it to set up your personal preferences. For BASH this is ~/.bash_profile. Put export variable=whatever in your ~/.bash_profile and it should get run when you run bash -l.

if i go to etc/profile I see different path than /usr/bin:/usr/local/bin:/usr/bin/usr/sbin:/usr/ucb:/usr/local/bin

So where is this PATH variable located?

---------- Post updated at 03:58 PM ---------- Previous update was at 03:56 PM ----------

So for setting global variable which means if i log in to 2 instances of putty and see the same path variable I need to modify ~/.bash_profile??? Is that correct???

What about the .profile in my home directory?? How is that different??

These files are scripts. It's possible for PATH to be set in more than one location -- .bash_profile could add to the end of a PATH set by /etc/profile, for example.

I repeat, they're not global variables.

I don't know why you'd expect to see two different PATHs when you logged in twice, but yes, you can put the changes you want into ~/.bash_profile.

.profile is what ksh uses, .bash_profile is what bash uses. Different local profiles for different shells make sense, otherwise you could end up with bash-specific commands causing ksh to throw up and ksh specific commands causing bash to throw up.

Again, these are script files, so it's possible for them to source other files too. Look at what's in them.