title: BASH: Check if user is root
body: <p>How can I check whether a user is root or not within a BASH script?</p>
  
  <p>I know I can use</p>
  
  <pre><code>[[ $UID -eq 0 ]] || echo "Not root"
  </code></pre>
  
  <p>or </p>
  
  <pre><code>[[ $EUID -eq 0 ]] || echo "Not root"
  </code></pre>
  
  <p>but if the script was invoked via fakeroot, UID and EUID are both 0 (of course, as fakeroot fakes root privileges).</p>
  
  <p>But is there any way to check whether the user is root? Without trying to do something only root can do (i.e. creating a file in /)?</p>