LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 01-27-2006, 11:56 PM   #1
suavecu
Member
 
Registered: Dec 2005
Location: Brooklyn
Distribution: Slackware 10.2
Posts: 87

Rep: Reputation: 15
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
 
Old 01-28-2006, 12:03 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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
 
Old 01-28-2006, 12:17 AM   #3
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445
Blog Entries: 9

Rep: Reputation: 45
I put my custom PATH variable in my .bashrc. The line looks like
Code:
export PATH="<whatever I want here>"
Hope this helps!
 
Old 01-28-2006, 12:26 AM   #4
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 61
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
 
Old 01-28-2006, 12:35 AM   #5
suavecu
Member
 
Registered: Dec 2005
Location: Brooklyn
Distribution: Slackware 10.2
Posts: 87

Original Poster
Rep: Reputation: 15
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.
 
Old 01-28-2006, 12:42 AM   #6
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
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.
 
Old 01-28-2006, 12:44 AM   #7
suavecu
Member
 
Registered: Dec 2005
Location: Brooklyn
Distribution: Slackware 10.2
Posts: 87

Original Poster
Rep: Reputation: 15
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.
 
Old 01-28-2006, 12:45 AM   #8
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
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.

Last edited by megaspaz; 01-28-2006 at 12:46 AM.
 
Old 01-28-2006, 01:09 AM   #9
suavecu
Member
 
Registered: Dec 2005
Location: Brooklyn
Distribution: Slackware 10.2
Posts: 87

Original Poster
Rep: Reputation: 15
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.
 
Old 01-28-2006, 01:10 AM   #10
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
.<filename> makes that file hidden in *nix/linux.
 
Old 01-28-2006, 01:27 AM   #11
suavecu
Member
 
Registered: Dec 2005
Location: Brooklyn
Distribution: Slackware 10.2
Posts: 87

Original Poster
Rep: Reputation: 15
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.
 
Old 01-28-2006, 01:44 AM   #12
suavecu
Member
 
Registered: Dec 2005
Location: Brooklyn
Distribution: Slackware 10.2
Posts: 87

Original Poster
Rep: Reputation: 15
LOL, had to reboot for the settings to take effect, duh. It works now, thank you everyone for your help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PATH variable jk21 Linux - Newbie 1 09-28-2004 03:48 PM
$path variable ? moby Linux - Newbie 3 06-01-2004 04:18 PM
the path variable mjkramer Linux - Newbie 4 10-18-2003 08:18 AM
how to remove PATH variable? greg108 Linux - Newbie 2 08-22-2003 02:55 PM
Help setting $PATH variable Nylex Linux - General 9 08-09-2003 12:44 PM


All times are GMT -5. The time now is 12:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration