Hello,
I am a newbie in Linux and am studying the bash shell.
I set an environment variable A1=100 (export A1=100).
After that, I executed each commands in the title.
The username is the same one as the one I am logging in.
What I expected is:
However, what I got is:
In other words, environment variable is not copied to the shell executed by sudo command (or reset after executing the shell? How by sudo -s?), and is not reset by executing the login shell (bash -l).
I expected that the environment variable is copied to the non-login sub shell, but is reset by executing the login sub shell.
I am not able to understand the results and why.
Please help me! understand the results.
Thank you.
I am a newbie in Linux and am studying the bash shell.
I set an environment variable A1=100 (export A1=100).
After that, I executed each commands in the title.
The username is the same one as the one I am logging in.
What I expected is:
commands executed | value of A1 |
bash -l su - username sudo -i -u username | undefined |
bash su username sudo -s -u username | 100 |
However, what I got is:
commands executed | value of A1 |
su - username sudo -i -u username sudo -s -u username | undefined |
bash bash -l su username | 100 |
In other words, environment variable is not copied to the shell executed by sudo command (or reset after executing the shell? How by sudo -s?), and is not reset by executing the login shell (bash -l).
I expected that the environment variable is copied to the non-login sub shell, but is reset by executing the login sub shell.
I am not able to understand the results and why.
Please help me! understand the results.
Thank you.