Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

Is there a method to set up an upstart script to execute a user-space program without keeping root privileges, but so the user which has directory/permissions-based ownership of the program can stop/start while still having the program start at boot time?

share|improve this question
Also, if anyone can point me to examples of upstart scripts that'd be awesome – Thomas Ward Jun 1 '12 at 19:25

Yes, with sudo:

sudo -u lordoftime program

-u + username start the program as that user.

share|improve this answer
Will this also use user-space environment stuff, such as ~/.progfolder/? – Thomas Ward Jun 1 '12 at 19:17
@LordofTime: As far as I read in the man page, you can use -H to set the home, and -i to start the loginshell of the user, thereby reading some configuration files. There are multiple blocks in the manpage refering to ENV, I don't like to cite complete. Read it up yourself, try it out and tell us, if you experience further problems. – user unknown Jun 1 '12 at 20:00
Thank you! Short, gets the job done, and doesn't beat around the bush – Nuzzolilo Jan 3 at 0:31

Problem using su trick with system jobs the user has no control over that job. It is still a system job, despite running as given user.

Proper solution in 12.04 is using user jobs. Those jobs live in each user's $HOME/.init and are fully controllable by that user. They also do not have root powers as user job is always run as that user's credentials. Otherwise they act just as system jobs, so you can define start onstanzas just like system jobs.

By default, Upstart jobs have no environment set except what is defined in the job. You can circumvent that by exec'ing via sh -l (exec /bin/sh -l -c "exec YOUR STUFF HERE").

share|improve this answer
Does this work with 11.04, the system which this is going to be in use on? – Thomas Ward Jun 6 '12 at 12:49
See Cookbook about enabling user jobs in prior to 12.04: Then it should work (0.9.7 in 11.04 is about the same as 1.3 in upstream). – Tuminoid Jun 7 '12 at 5:44

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.