LinuxQuestions.org
Visit Jeremy's Blog.
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 10-28-2009, 05:18 PM   #1
scucci
Member
 
Registered: Sep 2009
Posts: 31

Rep: Reputation: 15
Export PATH


I was just reading about the command "Export PATH" and wasn't quite sure why this had to be done? This has confused me in the past.

Thanks.
 
Old 10-28-2009, 05:42 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 281Reputation: 281Reputation: 281
Basically you only have to export your path if you change it. Otherwise, changes won't take effect until after a logout/login.
 
Old 10-28-2009, 05:44 PM   #3
lwasserm
Member
 
Registered: Mar 2008
Location: Baltimore Md
Distribution: ubuntu
Posts: 184

Rep: Reputation: 41
After you set a path it will be used by the current shell. If you don't export that path, any programs you run from the current shell will inherit the PATH that existed when the current shell was started. This applies to other variables as well. When you export PATH or export VARIABLE in general, that variable is available in the environment of the programs you run from the current shell. I agree it can be confusing at first, but after you work with the concept a little while it will seem natural and logical.
 
Old 10-28-2009, 08:14 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Not quite; any setting in the current shell (ie not exported) will be picked up by programs in the current shell level, but not by any sub-shells. What export does is 'export' (sic) those variables to all sub-shells/envs created from that shell ie unless you call a shell by

source x.sh

OR

. x.sh

non-exported vars will not be avail to the new shell.

http://www.ibm.com/developerworks/library/l-bash.html
 
  


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
Ubuntu 8.04 loses my $PATH. Why do I have to repeatedly export PATH= ? oouc Ubuntu 10 09-13-2009 11:54 PM
export Path=/usr/java:$Path does not seem to work lumix Linux - Newbie 1 03-19-2007 03:11 PM
problems with export (path) mac1234mac Linux - Software 2 03-17-2006 03:04 AM
export path command davidleroux1 Mandriva 8 01-19-2006 08:22 PM
export PATH disappears twallstr Linux - General 4 12-13-2004 02:57 AM

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

All times are GMT -5. The time now is 04:58 PM.

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