Mar
28th
Mon
28th
Run Linux command as a different user
It’s easy to forget how powerful the unix su command is. You can have it launch a different shell than the one specified in /etc/passwd, and tell it to run a particular command.
This comes in especially handy when adding startup tasks in /etc/rc.local, when you want to launch a server or some other process as an unprivileged user:
su -s /bin/sh - edarwin -c "/usr/local/erasmus/startup-debian.sh"
That is, as user edarwin, use the /bin/sh shell in a fresh environment to run the script startup-debian.sh.
Via this forum post.