LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   set PATH permanenly (https://www.linuxquestions.org/questions/linux-newbie-8/set-path-permanenly-280353/)

deucedlt 01-20-2005 09:44 PM

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?

jschiwal 01-20-2005 10:06 PM

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.

mabus92920 01-20-2005 11:23 PM

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 /

Linux~Powered 01-20-2005 11:52 PM

To make the path global you have edit the PATH in /etc/profile

Dillius 01-21-2005 01:42 AM

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.

caps_phisto 01-21-2005 03:09 AM

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.

Linux~Powered 01-21-2005 04:08 AM

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:

NVRAM 01-21-2005 10:42 AM

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.]

deucedlt 01-22-2005 10:48 AM

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)

gnom 02-25-2005 06:28 PM

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

gnom 02-25-2005 06:30 PM

Ooops.

sorry folks, I just had to change my keybord settings.

IBall 02-25-2005 08:43 PM

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


All times are GMT -5. The time now is 02:18 PM.