[thelist] Re: Adding to PATH in Linux

Kevin Martin kevin at brasscannon.net
Thu Nov 8 05:50:08 CST 2001


Quoth "Chris Johnston" <chris at fuzzylizard.com>
> trying to add it to the path variable. Here are the specs that you need
> to know to help me with this problem:

The flavor of Linux and JDK don't really matter.  This tells us what we 
need to know, though:

> I am tried this as both root and as a normal user and what is happening
> is that while I have the terminal open the new PATH stays and I can run
> java and javac from anywhere and they work. However, if I close the
> terminal and then reopen it again, the new PATH is gone and I have to
> reenter it.

When you close your terminal, that's the end of that session ("process"), 
and you've only redefined your PATH for the duration of that process (and 
its children, if any).  Does that make more sense?  "export" can't go 
backwards to before you opened your terminal; it can only go forward.

So:  You need to set your PATH at login, before X starts up.  You can do 
that by putting the re-definition into your .profile or .bash_profile, or 
into the system-wide profile /etc/profile.  If you want a system script 
to use it, it's better to set a complete explicit PATH in that 
script* rather than hoping the default system environment will work.

*(Find out exactly what directories you need in your PATH, and instead of  
using "$PATH plus one or two," define them ALL.  Again, this will only be 
in effect for the duration of the script.)

Generic advice:  Don't "hope" (make assumptions) about things -- the point 
of Linux is that you can "make it so!"  You find it frustrating now; I 
understand.  You may come to find it liberating.  I just think it's nice 
to have a choice.

http://handsonhowto.com/unix101.html  might help.




More information about the thelist mailing list