How to make ubuntu service run as specific user
10,922
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.
Related videos on Youtube
Author by
王子1986
Updated on September 18, 2022Comments
-
王子1986 over 1 year
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?
-
Rinzwind about 11 yearsYou 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.
-
-
InteXX almost 8 yearsThe 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.
-
Rinzwind almost 8 years1. 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.
-
InteXX almost 8 yearsI'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 :-)