I am editing a init.d script. The init.d script runs a utility script which then runs an process. From either bash scripts how would I make it launch the main process as a specific user and group?
Launch process as another user/group (in init.d script)
initprivilegesprocess
Best Answer
The simplest way is to use the su(1) command, it has an option that allows you to run a command via the user's shell, example:
This will switch to the user foo and run the ls command. If the user you want to use does not have a valid shell (ie it's not in /etc/shells, like /bin/false or /sbin/nologin) you will also have to specify a shell on the command line. Example with output: