title: Difference between setuid and seteuid function
body: <h2>Program 1: Example with setuid()</h2>
  
  <pre><code>    #include&lt;stdio.h&gt;
      #include&lt;sys/types.h&gt;
      #include&lt;unistd.h&gt;
      void main()
      {
          printf("Real user id = %d, Effective User id = %d\n",getuid(),geteuid());
          setuid(1000);
          printf("Real user id = %d, Effective User id = %d\n",getuid(),geteuid());
          setuid(1014);
          printf("Real user id = %d, Effective User id = %d\n",getuid(),geteuid());
      }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>    guest $ ./a.out 
      Real user id = 1000, Effective User id = 1014
      Real user id = 1000, Effective User id = 1000
      Real user id = 1000, Effective User id = 1014
      guest $
  </code></pre>
  
  <h2>Program 2: Example with seteuid()</h2>
  
  <pre><code>    #include&lt;stdio.h&gt;
      #include&lt;sys/types.h&gt;
      #include&lt;unistd.h&gt;
      void main()
      {
          printf("Real user id = %d, Effective User id = %d\n",getuid(),geteuid());
          seteuid(1000);
          printf("Real user id = %d, Effective User id = %d\n",getuid(),geteuid());
          seteuid(1014);
          printf("Real user id = %d, Effective User id = %d\n",getuid(),geteuid());
      }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>    guest $ ./a.out 
      Real user id = 1000, Effective User id = 1014
      Real user id = 1000, Effective User id = 1000
      Real user id = 1000, Effective User id = 1014
      guest $
  </code></pre>
  
  <p>Both programs give the same output. So, what is the difference between these two functions? As per the reference (man page), both functions are used to set the effective user ID of the process. Where does the functionality differ between these two programs?</p>