Reputation: 15
After searching all over the internet, I came know where to alter the values of PATH variable in case of interactive/non-interactive - login/non-login shell combinations.
Found from another post
https://shreevatsa.wordpress.com/2008/03/30/zshbash-startup-files-loading-order-bashrc-zshrc-etc/
I have "/bin/sh" as default login shell and only /etc/profile file is being used to export all needed environment variables in my system. And in case of non-interactive login shell, /etc/profile is not being referred too, even though above link says it would. But still when I execute,
ssh -4 -q -o StrictHostKeyChecking=no root@xxxx "env"
Password:
SHELL=/bin/sh
...
**PATH=/usr/bin:/bin:/usr/sbin:/sbin**
...
I could see some default values for PATH variable. I would like to know where exactly these default values of PATH are being set.
Upvotes: 1
Views: 2360
Reputation: 30718
It depends on your distribution. In Debian and its derivatives, the definition is found in /etc/environment
and it is read into the current session by inclusion of pam_env.so
in the appropriate /etc/pam.d/
files.
Upvotes: 0
Reputation: 72639
You should not care at all where PATH
is set. You should set PATH
always in your shell startup file (.profile
or .bashrc
).
This way you do not rely on someone else's soon useless assumption what directories should be in your PATH
. The only one who knows is YOU.
Start out with
PATH=$(getconf PATH)
and then add to your liking with
PATH=$PATH:$HOME/bin
PATH=$PATH:/usr/local/bin
PATH=$PATH:<...any other directory you need...>
PS: In your specific case, it looks like the PATH
is inherited from the remote end's SSH daemon which eventually forks your shell. If a shell does not inherit a PATH
from its parent, it will set a default value that you can query with env -i /bin/sh -c 'echo $PATH'
.
Upvotes: 1