Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to make ubuntu service run as specific user?

I created an init.d script and make it start at boot, but sooner I found the service is running as root after reboot.

I google and google, people suggest run as a seperate user, so what's the steps?

share|improve this question
You should specify for what Ubuntu you want this. Not all Ubuntu have upstart v1.4 so I will assume 12.04, 12.10 or 13.04. – Rinzwind Apr 24 '13 at 9:58
up vote 4 down vote accepted

Upstart v1.4+ states ...

setuid $user

Changes to the user before running the job's process.

  • Change $user to an actual username
  • Note that all processes (pre-start, post-stop, et cetera) will be run as the user specified.
  • Note that if you specify an invalid username in the setuid stanza, Upstart will log an error if it is in Debug Mode.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.