I know that environment variables are set through reading or executing several configuration files, such as /etc/environment, /etc/profile, ~/.profile, ~/.bashrc, etc.
But when I was reading this blog post, I tried to start a non-login interactive bash shell without importing environment, using the following command:
osboxes@osboxes:~$ env -i bash
After getting into the new shell, I checked the PATH variable, and got the following result:
osboxes@osboxes:/home/osboxes$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.
As far as I know, this non-login interactive shell doesn't read /etc/environment or source /etc/profile or ~/.profile; it only sources /etc/bash.bashrc and ~/.bashrc.
So how is the PATH variable in this shell set? Is there a specific file to read or source from?
~/.bashrcfile do? You could try also settingHOMEto some other directory to avoid picking up that file at all, or use--norc. There will still be aPATHthough, if not for any other reason than that the shell assumes a minimalPATHvalue which is hardcoded into thebashexecutable.