Is there a way to have an application launch during startup under a certain user account?
For example, I would like to have a_small_app
run under the user account bob
(which is in the group bobsgroup
). Do I add something to /etc/init.d
?
Note: I don't want the application to start after a user logs in but rather when the computer starts.
Best Answer
A startup system agnostic method. You can use this in
/etc/rc.local
, a/etc/init.d/...
script, an Upstart configuration file and probably a systemd configuration too.This command will run as the root user and
sudo
will drop down to the "oli" user. Obviously change the user and the command for your purposes.I should add that there are at least a dozen ways of doing just this... But in my experience they're all largely identical in effect. Here's an upstart example using its
setuid
stanza: