[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to add dir to path



Nyizsnyik Ferenc wrote:
> On Wed, 8 Aug 2007 18:38:49 +0200
> "Manon Metten" <manon.metten@gmail.com> wrote:
>
>   
>> Hi,
>>
>> This thread ain't over yet. Apart from using ~/bin (as Andrei Popescu
>> suggested) I noticed that adding 'export PATH=$HOME/scripts:$PATH'
>> to the end of ~/.bash_profile, the newly added dir is not available in
>> any new session I open. However, when I open a new bash window,
>> the new dir is available. Something like this:
>>
>> Bash Win1
>>   - Session 1: ~/scripts   YES
>>   - Session 2: ~/scripts    NO
>>     ...
>>   - Session X: ~/scripts    NO
>>     

This is because environment variables are per-process in unix, not
global.  If you set (and export) an environment in a shell, it only
affects that shell and any child processes.  If you want to pick this up
in the other shells, explicitly source the file with '. ~/.bash_profile'

> Adding $HOME to /etc/profile should not work the way you want it to.
> These settings are global, consider them as "executed by root", so in
> this case $HOME will resolve as /root, not /home/manon as you may have
> expected.
>   

No, this is not the case at all.  /etc/profile is read by all
bourne-derivatives at login as the user running the login shell.  If
you're logging in as root, then it is sourced as root, if you are
logging in as bob, then it is sourced as bob.




Reply to: