title: Why does sudo change the PATH?
body: <p>This is the <code>PATH</code> variable without sudo:</p>
  
  <pre><code>$ echo 'echo $PATH' | sh 
  /opt/local/ruby/bin:/usr/bin:/bin
  </code></pre>
  
  <p>This is the <code>PATH</code> variable with sudo:</p>
  
  <pre><code>$ echo 'echo $PATH' | sudo sh
  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
  </code></pre>
  
  <p>As far as I can tell, <code>sudo</code> is supposed to leave <code>PATH</code> untouched. What's going on? How do I change this? (This is on Ubuntu 8.04).</p>
  
  <p>UPDATE: as far as I can see, none of the scripts started as root change <code>PATH</code> in any way.</p>
  
  <p>From <code>man sudo</code>: </p>
  
  <blockquote>
    <p>To prevent command spoofing, sudo
    checks ``.'' and ``'' (both denoting
    current directory) last when searching
    for a command in the user's PATH (if
    one or both are in the PATH). <strong>Note,
    however, that the actual PATH
    environment variable is not modified
    and is passed unchanged to the program
    that sudo executes.</strong></p>
  </blockquote>