title: Trying to understand how the PATH is set on linux (bash on Ubuntu 16.04)
body: <p><hr/>
  EDIT</p>
  
  <p>The answer to my question is actually obvious, I simply forgot about the meaning of the EXPORT keyword. I still drop the explanation here, just in case.</p>
  
  <p>So in a few words, when opening a terminal with Ctrl-Alt T a new shell is created, which is a child of the shell created at loggin. As explained <a href="https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html" rel="nofollow noreferrer">here</a>, the loggin shell is initialized by reading <em>/etc/profile</em>, and as explained <a href="https://www.gnu.org/software/bash/manual/html_node/Command-Execution-Environment.html" rel="nofollow noreferrer">here</a> and more specifically <a href="https://www.gnu.org/software/bash/manual/html_node/Environment.html#Environment" rel="nofollow noreferrer">here</a> elements of the environment are transmitted to child processes, notably variables prefixed with the EXPORT keyword.</p>
  
  <p><hr/>
  I am trying to understand what is the mechanism under which the <code>PATH</code> is set under linux when opening a new (virtual) terminal.</p>
  
  <p>I know one can change the <code>PATH</code> in several files (e.g. system : <em>/etc/{profile</em>, <em>bash.bashrc</em>, ... } or user: <em>~/{.profile</em>, <em>.bash_login</em>, <em>.bashrc</em>... }, some of which are read at login, the others when opening new (virtual) terminals.</p>
  
  <p>According to my tests, it seems the "<em>profile</em>" files are read at startup (when the user logs in), which registers some startup values for variables such as <code>PATH</code>. Then, each time a terminal is opened these startup values are provided to other script (e.g. <em>bashrc</em>) for further configuration, resulting in something like : <code>PATH_IN_TERMINAL=$BASHRC_ADDONS:$PATH_FROM_PROFILE</code></p>
  
  <p>Notably, <em>~/.profile</em> won't normally be read after login. Changing this file won't have any effect in the current session and the <code>PATH_FROM_PROFILE</code> part of the <code>PATH</code> will remain the same until one logs in again (after logout or through ssh connection for instance).</p>
  
  <p>Am I correct ? And if so, where can I find a doc on the subject ?</p>
  
  <p>Thanks</p>