Jump to content

Forgive the noob question - what is $PATH?


oRGy
 Share

Recommended Posts

Greetings.

 

This $PATH variable, then. Apparently my Java isn't typically found because it isn't in my path, along with some other stuff.

 

1) How does one edit this PATH variable. I remember it used to be so simple in the DOS days.

 

2) Are there different $PATHS for root and normal users?

 

3) Any tips?

 

Thanks in advance. Forgive my ignorance in this matter.

Link to comment
Share on other sites

1) i believe your $PATH is set in .bash_profile or .bashrc, although my memory is a bit foggy on this....

 

2) yes. the major difference is that root usually has /sbin (or /usr/sbin) included in it's paths.

 

3) some paths that aren't always in the $PATH that some programs may reside in: /usr/local/bin is very common. i don't remember if lib paths are defined in the path variable, but /usr/local/lib might also be needed.

 

i could be a bit off, and if i am, i'm sure the resident garu will jump in and correct me.

Link to comment
Share on other sites

You actually sure you've got Java installed? The Sun Java package is not included in the download edition of MDK as its propriety. MDK does ship with Kaffe which can do the same job (I think) but you'd be better off with Sun's offering. Its freely avilable to download from several sites as an RPM so it should just work without need to playing around with the path.

Link to comment
Share on other sites

OK, to see the variable $PATH type

echo $PATH

 

set set it in a c-shell type

setenv PATH /bin;/usr/bin/;<path to jre>

 

in bash you'd type

PATH=/bin;/usr/bin/;<path to jre>

 

but this wouldn't make it available to another class, you would need to explicitly export it with

export $PATH

 

you can put these together as:

PATH=/bin;/usr/bin/;<path to jre> ;export $PATH

or

export PATH=/bin;/usr/bin/;<path to jre>

 

You can use an envvar in a delaration...

i.e.: export $PATH;<path to jre> will append your jre path to whatever PATH was set to.

 

Whilst we are on it you could also see your path by

env |grep PATH

 

note : you should see a var called LD_LIBRARY_PATH ... this is important and we'll get to it later.

 

try an

env |more

 

you'll see lots of environment varaibles.....

You set the the same way....

 

export DISPLAY=<anotherhost:0.1> will make the next Xwindow start on anotherhost in the second Xserver.

 

 

So back to the tip....

If your user has a bash shell you'd set PATH in the .bashrc

If your user has a cshell you can set it in .cshrc

 

These are parsed everytime you start a new process for that user....

IMPORTANT: This is the difference between

su <youruser> and

su - <youruser>

the latter reparses the login scripts....

 

You can also set the path for a specific process. i.e. you have a bash script you weant to run a program, you can for instance

#!/bin/sh

export PATH=$PATH;<myfunnyapp'spath>

myfunnyapp

 

The path will only be set for processes started from that shell.

This is known as inheritance.

 

TRY THIS

Open two terminals sperately with youruser

In one type:

export SILLYENVVAR=foo

then type

echo $SILLYENVVAR

it will tell you foo

 

In the other window type

echo $SILLYENVVAR

it will give you a blank line.

 

Now:::::

From the 1st terminal where you set the envvar type xterm

if you have xterm installed and in your path it will open an xterm...

if not you need to type whatever console type program you have installed.

 

It will opena new terminal/xterm

now type:

echo $SILLYENVVAR

 

It will tell you foo becuase it was inherited from its parent....

You can use the concepts of scope and inheritiance do do quite sophisticated stuff.

 

back to LD_LIBRARY_PATH.....

This is where it looks for the linked libraries from the compilation. Java will change them.....

It has its own linked paths to its own libraries....

 

If you install the RPM, you are root.....

The LD_LIBRARY_PATH will be set for the scope of that install for the root process.

You need to add this to your user path ....for LD_LIBRARY_PATH....

 

You can do this lots of ways, the simplest is in the user .cshrc OR .bashrc

 

Try and get your head round these concepts ....

They are commonly difficult for people coming from a Windows background becuase windows doesn't have them....

 

Hope this helps

Link to comment
Share on other sites

dang Gowator, you're gonna scare people away giving 'em so much info all at once ;-)

 

orgy: if i remember correctly, what you need to do is find the "java" file installed by 1.4.1 and make a link in /usr/bin to it:

ln -s /path/to/java /usr/bin/java

 

(this has to be done as root.)

Link to comment
Share on other sites

Yep, i got kinda carried away.

 

i installed jre under RH7.0 which was a NIGHTMARE.

 

Two different glibc's to link to.

Strange thing it was for the Oracle installer. The install was much more demanding than the actual program : go figure that one.

 

Anyway, i guess a FAQ for ex-windows users is crying out to be written on inheritance and scope. Ive seen it puzzle so many ex-Windows non programmers when really its easy.

 

I also picked up on your libraries pointer. The correct env variable is the LD_LIBRARY_PATH.

 

Anyway, I figure a little knowledge never hurt anyone. I guess I introdcued different shells, logins and stuff all at the same time...

perhaps a type this tutorial is in order ??

Link to comment
Share on other sites

in bash you'd type

PATH=/bin;/usr/bin/;<path to jre>

...

 

You are wrong!

 

Don't be scared, just a few notes about your excellent post :D

 

It is not ';' but ':' the character to be used to separate directories in the PATH variable. Like this:

export PATH=$PATH:/path/to/something/:/another/path:/bin

 

Remember that ';' is the character used to indicate the END of a command, so it cannot be used in this context.

 

Notice the $PATH in PATH=$PATH:... means to append new directories to the current PATH. No need at all to retype again the full path ;)

...

note : you should see a var called LD_LIBRARY_PATH ... this is important and we'll get to it later. 

...

I'm almost sure that that variable won't exist in oRGy's env output, since it is more common to edit the file /etc/ld.so.conf and run /sbin/ldconfig to achieve the same result. But I'm not sure if ldconfig works for Java too, so probably you are right and oRGy should use LD_LIBRARY_PATH

 

PS: Oooops! you said also to do "export $VARIABLE". That won't work, it is "export VARIABLE". Doing as you suggested you'll be exporting the VALUE of the variable instead of the variable itself. Try it with the "son terminal trick" you used in your example and you'll see that your way wont work :)

Link to comment
Share on other sites

We are not worthy .... we are not worthy .....

 

Thanks, Garu. Hopefully people don't forget man.

I get windowised when at work.....and have to do it from memory in any case.

 

Eeek, your right errant $$$$ signs creeping in....

So how about doing a tutorial aru.....

 

I thought type this and see what it does. I know lots of people who are non programmers who just don't get inheritance.... Its not hard, its just a foreign concept for Win$ users.

 

The linker stuff kinda came to me because I expected it in his grep. Anyway its a bit old, it was stuff I discovered back in Oracle 8.1.2 installer for Linux. When I look back its amazing what I learned trying to get the $PROFANITY installer working.....

 

Anyway, some other nice 'tricks' like ls *file* and such might prove helpful. I say tricks becuase really its logical, its just DOS behaved in an illogical way and people got used to it.

 

Oh and I forgot echo $SHELL

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...