title: System Shell Scripts Can't Find my Command in PATH
body: <p>I put a custom command (shell script) in <code>/usr/local/scripts/</code>.</p>
  
  <p>In order to see commands from <code>/usr/local/scripts</code>, I set the PATH using the following methods:</p>
  
  <ol>
  <li><p><code>sudo visudo</code></p>
  
  <pre><code>Defaults  secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/scripts"
  </code></pre></li>
  <li><p><code>sudo nano /etc/profile</code></p>
  
  <p>PATH="$PATH:/usr/local/scripts"
  export PATH</p></li>
  <li><p><code>sudo nano /etc/login.defs</code></p>
  
  <p>ENV_SUPATH      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/scripts
  ENV_PATH        PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/scripts</p></li>
  <li><p><code>sudo nano /root/.bashrc</code></p>
  
  <p>PATH="$PATH:/usr/local/scripts"
  export PATH</p></li>
  <li><p><code>sudo nano /etc/environment</code></p>
  
  <p>PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/scripts"</p></li>
  </ol>
  
  <p>And this works in most cases, but...</p>
  
  <p>I have two script which, in their code, calls a script from <code>/usr/local/scripts/</code>,  and it can't find my script!</p>
  
  <p>The first is <code>/etc/network/if-up.d/sendip</code>, which is run as root when the networking stack is initialized.</p>
  
  <p>And the second is <code>/usr/local/scripts/notif-login</code> which is run as root from <code>pam</code> by <code>/etc/pam.d/sshd</code>:</p>
  
  <pre><code>session optional pam_exec.so /usr/local/scripts/notif-login
  </code></pre>
  
  <p>If I run both script from my terminal shell, another user, with sudo, without sudo, after su, or login with root, it works properly. But when it is runner by the system (first when networking initialized, and the second via SSH) both failed to run scripts from <code>/usr/local/scripts</code>.</p>
  
  <p>Is there another place where I have to set the path?</p>