I have set some environment variables in the following way:
MY_VAR='helloworld'
export MY_VAR
Then I have switched to another user via
su SOME_OTHER_USER
I echo the MY_VAR variable.. and I see its value!
1) Could you please explain this issue. As far as I understand when I export variable via export command it is not a "global" export, its just a user-local variable. Why I see it?
2) Initially I had a guess: may be, when I switch to another user I start some child process of my bash process, and thats why I can see my variable because the exported vars are passed to any child process of current shell. But command ps ---pid <my bash's pid which I got with echo $$>
shows only the same pid in output. So looks like this means there are no child processes related to my bash process and su is not starting any process. Am I right?
(by the way, I dont see a single 'child' this way, even if I start another bash with bash command, I dont know why)
3) Finally, who can see the variable I have exported that way? Given I start some other process from my OS GUI - am I about to see it? Looks like no, because if I start another terminal I dont see it there. So what is the scope and lifetime of my exported variable?
I use Debian Wheezy. I was running my command from RootTerminal under Root user.