Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PATH question 3

Status
Not open for further replies.

superkingkong

Technical User
Feb 20, 2010
5
US
Hi guys,

I would like to know what is the difference between these two statement in my .profile

export PATH=$PATH:/usr/sbin/cluster/utilities

vs

PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr


Appreciate if you could help, thanks.
 
PATH= is your original PATH

Code:
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr

export PATH=$PATH:/usr/sbin/cluster/utilities

is just the same as saying

Code:
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr:/usr/sbin/cluster/utilities

if you type echo $PATH after you log in you should just see the above output, no real reason for doing it other than giving everyone the same initial PATH, then adding extra's to different users as required and remember the directories will be searched in the order they appear in the path.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Thank you for the explanation.

so, in other words,

export PATH=$PATH:/usr/java

is the same as

PATH=/usr/java

?
 
It depends. If your original $PATH is empty, yes. However, if your original $PATH did contain anything then /usr/java will be appended to it.

The internet - allowing those who don't know what they're talking about to have their say.
 
Thanks all.

I noticed that in my root .profile, there is something like this:

export PATH=$PATH:/usr/java6

PATH=/usr/bin

But, when i do a echo $PATH, lots of paths are being displayed, like /usr/sbin:/path/to/folder2:/path/to/folder3:/usr/java5:usr/java6:/usr/bin

Where do all these paths came from? i can't find it in my .profile.

My problem is, i would like to use java6. But java5 is in the path, which I don't see it in my .profile.

so, can I overwrite the $path in my .profile? I think PATH=/usr/java6 will only append to the end of the path.

Appreciate if you could help, thanks.

PS: the 2 statements above, can i combine them to one line, like export PATH=$PATH:/usr/java6:/usr/bin ? instead of having one export PATH and one PATH=bla bla bla

Thanks.
 
All the additional "paths" might be coming from PATH being set in /etc/environment. All the following does:

Code:
export PATH=$PATH:/usr/java6

is append /usr/java6 on the end of the original PATH variable being set somewhere else (i.e. /etc/environment).

You can try to edit /etc/environment and tailor it to your needs but remember, this will change it for everyone who logs in to the server. Another way that only affects your user is instead of append to the variable, you rewrite it completely:

Code:
export PATH=/some/directory:/another/directory:/and/yet/another/directory


Regards,
Chuck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top