LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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: 271Reputation: 271Reputation: 271
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: Centos 6.9, Centos 7.3
Posts: 17,362

Rep: Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377Reputation: 2377
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


All times are GMT -5. The time now is 06:23 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration