title: Best practice to run Linux service as a different user
body: <p>Services default to starting as <code>root</code> at boot time on my RHEL box. If I recall correctly, the same is true for other Linux distros which use the init scripts in <code>/etc/init.d</code>.</p>
  
  <p>What do you think is the best way to instead have the processes run as a (static) user of my choosing?</p>
  
  <p>The only method I'd arrived at was to use something like:</p>
  
  <pre><code> su my_user -c 'daemon my_cmd &amp;&gt;/dev/null &amp;'
  </code></pre>
  
  <p>But this seems a bit untidy...</p>
  
  <p>Is there some bit of magic tucked away that provides an easy mechanism to automatically start services as other, non-root users?</p>
  
  <p><strong>EDIT:</strong> I should have said that the processes I'm starting in this instance are either Python scripts or Java programs. I'd rather not write a native wrapper around them, so unfortunately I'm unable to call <a href="http://linux.die.net/man/2/setuid" rel="noreferrer">setuid()</a> as <a href="https://stackoverflow.com/users/25234/black">Black</a> suggests.</p>