LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   PATH variable (http://www.linuxquestions.org/questions/linux-software-2/path-variable-408798/)

suavecu 01-27-2006 10:56 PM

PATH variable
 
so I'm adding my java/bin directory to my PATH variable and I'm using the PATH=$PATH:/bla/bla/bla and I hit enter. I then try using the javac command to compile a program and everything is Kosher. However, as soon as I logout, or leave the console, the PATH variable reverts back to what it was before I added /bla/bla/bla.

I'm running free mandrake 2006 right now.

Anyone have any ideas?

Thanks ahead of time,

suavecu

pixellany 01-27-2006 11:03 PM

First hit on Google:
http://www.troubleshooters.com/linux/prepostpath.htm

Summary (from my feeble memory--not the site)

You need to export PATH to make it stick
You need to put it in a config file to be there on re-boot

microsoft/linux 01-27-2006 11:17 PM

I put my custom PATH variable in my .bashrc. The line looks like
Code:

export PATH="<whatever I want here>"
Hope this helps!

IBall 01-27-2006 11:26 PM

Quote:

Originally Posted by microsoft/linux
I put my custom PATH variable in my .bashrc. The line looks like
Code:

export PATH="<whatever I want here>"
Hope this helps!

That should be:
Code:

export PATH=$PATH:/path/to/directory
The difference is the first one will replace your $PATH with your new directory, so you will only be able to run whatever is in the new directory. The second one will append the new directory to the end of your current PATH, so you won't lose all your other commands :).

I hope this helps
--Ian

suavecu 01-27-2006 11:35 PM

Quote:

Originally Posted by IBall
That should be:
Code:

export PATH=$PATH:/path/to/directory
The difference is the first one will replace your $PATH with your new directory, so you will only be able to run whatever is in the new directory. The second one will append the new directory to the end of your current PATH, so you won't lose all your other commands :).

I hope this helps
--Ian

I'm trying that (export PATH=$PATH:/my/dir/for/bin) and the same thing happens. It updates my PATH variable, but when I leave the console it's gone. I even tried creating a JAVA_HOME, exporting that variable, then adding that to my path with the bin after it (export PATH=$JAVA_HOME/bin:$PATH), and when I left and came back the JAVA_HOME variable didn't exist anymore even though it worked when I tried it before I left the console.

This is driving me crazy. Anyone have any ideas?

Thanks again.

megaspaz 01-27-2006 11:42 PM

Quote:

Originally Posted by suavecu
I'm trying that (export PATH=$PATH:/my/dir/for/bin) and the same thing happens. It updates my PATH variable, but when I leave the console it's gone. I even tried creating a JAVA_HOME, exporting that variable, then adding that to my path with the bin after it (export PATH=$JAVA_HOME/bin:$PATH), and when I left and came back the JAVA_HOME variable didn't exist anymore even though it worked when I tried it before I left the console.

This is driving me crazy. Anyone have any ideas?

Thanks again.

pixellany answered that part of the question for you already.

suavecu 01-27-2006 11:44 PM

so it's this part that I am missing

Quote:

You need to put it in a config file to be there on re-boot
off to google I go.

megaspaz 01-27-2006 11:45 PM

Quote:

Originally Posted by suavecu
so it's this part that I am missing

Quote:

You need to put it in a config file to be there on re-boot
off to google I go.

microsoft/linux answered that part of the question and IBall gave you the correct line to put in that file.

suavecu 01-28-2006 12:09 AM

K, I had to put it in my /etc/profile file because the /etc/bashrc file said that all environment variables belonged in profile. That being said, I added the JAVA_HOME variable and then added the line export PATH=$JAVA_HOME/bin:$PATH and it worked.

Thank you everyone very much, as always it's greatly appreciated.

random question: as you can see I'm still a linux/linux lingo noob :) so why do people put .'s around a file name (like .bashrc.)

Thanks again.

megaspaz 01-28-2006 12:10 AM

.<filename> makes that file hidden in *nix/linux.

suavecu 01-28-2006 12:27 AM

Thank you for explaining that :) On a much less positive note, I logged back in, and it still doesn't work even though the .profile file has the path variables in it. So now I'm completely out of ideas :( I checked .profile and everything is still in there, only now it doesn't work. All I want to do is write some java code :(

Where would I enter it in the .bashrc file? There is nothing like it in that file, so I don't want to add something to somewhere where it shouldn't be.

suavecu 01-28-2006 12:44 AM

LOL, had to reboot for the settings to take effect, duh. It works now, thank you everyone for your help.


All times are GMT -5. The time now is 09:31 AM.