title: How to make passwordless switch to another user in a shell script
body: <p>I want to su from hadoopmaster to hduser. When I do it on the terminal, I do:</p>
  
  <pre><code>su - hduser
  </code></pre>
  
  <p>which then asks me for the password and I enter it and I get in to hduser. How can I do the same in a shell script without having to worry about the password? I tried the <code>sudoers</code> file method where I put:</p>
  
  <pre><code>root ALL=(ALL:ALL) ALL
  hduser ALL=(ALL:ALL) ALL
  hadoopmaster ALL=(ALL:ALL) NOPASSWD: /bin/su hduser 
  (here I tried different combinations of the line with and without the '-' and also 
  with and without /bin)
  </code></pre>
  
  <p>I did this and when I do <code>su hduser</code> or <code>su - hduser</code>, it prompts me for the password again. What do I do?</p>