LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-20-2005, 09:44 PM   #1
deucedlt
Member
 
Registered: Oct 2004
Distribution: Red Hat 9-2.4.20-31.9
Posts: 40

Rep: Reputation: 15
set PATH permanenly


i recently downloaded and installed j2re (java runtime environment) and was advised to
make sure java binary was in my PATH. i used export PATH="$PATH:/<path to java>"
which worked fine during current session but change went away when i logged out. does
anyone know how to make the changes permanent?
 
Old 01-20-2005, 10:06 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can edit your ~/.bash_profile command and add 'PATH=$PATH:<path to java>"
export path

If there isn't a ~/.bash_profile, bash looks for ~./bash_login or ~/.profile. If you don't have one of these files, you can create one.

It is better to use a login script for this, because if you used ~/.bashrc instead, it would be executed every time you started another shell. The result you be the $PATH variable growing with the same path being added to the end.

Last edited by jschiwal; 01-20-2005 at 10:08 PM.
 
Old 01-20-2005, 11:23 PM   #3
mabus92920
Member
 
Registered: Jan 2005
Posts: 48

Rep: Reputation: 15
that is if you want to set path for individual users..if you want to set path's as global..you have to edit bashrc under /
 
Old 01-20-2005, 11:52 PM   #4
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slackware 14.2
Posts: 849

Rep: Reputation: 33
To make the path global you have edit the PATH in /etc/profile
 
Old 01-21-2005, 01:42 AM   #5
Dillius
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: Debian Etch
Posts: 99

Rep: Reputation: 15
I have also been trying to do this, but I have had no kind of luck getting the path set to work. I'm running Mandrake 10.1, and in my /etc/profile i have ->

PATH="$PATH:/usr/X11R6/bin:/usr/java/jdk1.5.0_01/bin"

I have no idea why it's not working, or if I have to add more variables than that.
 
Old 01-21-2005, 03:09 AM   #6
caps_phisto
Member
 
Registered: Sep 2004
Location: NH
Distribution: FC6, FC1-4, RH9, Gentoo 2006.0/1, Slackware 10.1/2,11, Vector SOHO 5.0.1
Posts: 237

Rep: Reputation: 30
If your entry does look like this
PATH="$PATH:/usr/X11R6/bin:/usr/java/jdk1.5.0_01/bin"

Try removing those quotes, I'm pretty sure you do no need them.
 
Old 01-21-2005, 04:08 AM   #7
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slackware 14.2
Posts: 849

Rep: Reputation: 33
The quotes are supposed to be there. Do you have the correct path?
Should be something like...

:/usr/lib/java/bin:/usr/lib/java/jre/bin:
 
Old 01-21-2005, 10:42 AM   #8
NVRAM
LQ Newbie
 
Registered: Oct 2004
Location: Western USA
Distribution: Fedora,Suse,Redhat,Puppy,etc.
Posts: 13

Rep: Reputation: 1
To state what may be obvious, check the "PATH=" line mentioned, and be sure that:
- this line is actually executed (remember that there are functions, "case" and "if/then" statements there), and
- the line isn't later superceded by a PATH= line that doesn't preserve your additions (ie: It doesn't have $PATH after the equal sign).
Adding it as the last line in the "/etc/profile" file should fix both potential problems.

That should fix it, but instead I'd suggest you add a file under /etc/profile.d, with a ".sh" suffix -- it will be used with BASH, SH, KSH, etc.

echo 'PATH="$PATH:/usr/java/jdk1.5.0_01/bin"' > /etc/profile.d/java-1.5.0.sh

If you're still having issues, tell us what distro+version you're running, what shell you use, what you *do* have for your $PATH and the output of:
grep PATH= /etc/profile /etc/profile.d/*.sh ~/.bash* /etc/bashrc

Cheers

Incidentally, as long as there aren't any spaces or shell syntax tokens in the variable assignments, the double quotes are optional.
[Here "tokens" include: parens, pipes, ampersands, greater/less than, and probably a few others I forgot.]
 
Old 01-22-2005, 10:48 AM   #9
deucedlt
Member
 
Registered: Oct 2004
Distribution: Red Hat 9-2.4.20-31.9
Posts: 40

Original Poster
Rep: Reputation: 15
thanks for all he input. what i finally did (that worked)
was add line to .bashrc (in both /home/user and /root)

export PATH=/my/old/path:/path/addition

which i then edited by deleting an extra instance of he path components '/home/user/bin and /root/bin' which
the above command for unknown reason added to the
end. (i deleted the instance at the end of the original
path)
 
Old 02-25-2005, 06:28 PM   #10
gnom
LQ Newbie
 
Registered: Feb 2005
Distribution: RedHat 9
Posts: 2

Rep: Reputation: 0
This thread has just helped me to install maple 9 on Mandrake 10.1, thank you!

However a very strange thing happens once I try to use xmaple.
I can start and use it but the backspace button on my keyboard (a german one) will not work. Worse than that is that e.g. x² will not work with the usual "to the power of" button.

I hope I am not asking complete nonsense, but I am still very new in the linux world.

Cheers
 
Old 02-25-2005, 06:30 PM   #11
gnom
LQ Newbie
 
Registered: Feb 2005
Distribution: RedHat 9
Posts: 2

Rep: Reputation: 0
Ooops.

sorry folks, I just had to change my keybord settings.
 
Old 02-25-2005, 08:43 PM   #12
IBall
Senior Member
 
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Quote:
Originally posted by deucedlt
thanks for all he input. what i finally did (that worked)
was add line to .bashrc (in both /home/user and /root)

export PATH=/my/old/path:/path/addition

which i then edited by deleting an extra instance of he path components '/home/user/bin and /root/bin' which
the above command for unknown reason added to the
end. (i deleted the instance at the end of the original
path)
A better place to put that line is in ~/.bash_profile. This is because this file is only read when you login. ~/.bashrc is read each time you start an xterm, so your path will get longer and longer...

I hope this helps
--Ian
 
  


Reply



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
can't set PATH gsrichmo Linux - Software 6 07-16-2005 01:21 PM
Set the path systemwide/Set the path for a user with Slackware jayhel Slackware 1 06-12-2005 12:24 AM
9.1 set $PATH seingoku Slackware 6 02-06-2004 03:12 PM
How to set PATH How do I set PATH environment variable? Tranquil Linux - Newbie 3 11-02-2003 02:52 AM
$PATH!? how to set these PATH(s)!? sirpelidor Red Hat 5 10-25-2003 04:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:17 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
Open Source Consulting | Domain Registration