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
1  
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
    
The documentation for this is huge and hideously complex. What are the simple steps to configure this? Edit a file somewhere? How to edit such file? Thanks. – InteXX May 24 at 20:49
1  
1. It is not simple and it is different across different Ubuntu's... 16.04 dropped upstart and uses systemd so most of us do not even use it anymore ;-) 2. depends on the procedure. In general you edit the file in /etc/init.d/ for the procedure you want to edit. The current files there should give some info on how to do this 3. vim, nano, gedit. – Rinzwind May 25 at 6:40
    
I've been reading about the systemd issue and the fork. It seems there's been a bit of a row over the thing. Myself I'm not partial—if I can accomplish what I need, then I'm happy. This is a friend's older laptop anyway... I'll just wipe it clean and put the latest Lubuntu on it, which as you point out comes with systemd by default. Problem solved. So thank you for the brief education :-) – InteXX May 25 at 18:10

Your Answer

 
discard

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.