Re: how to execute a command as another user in one command?
Star Liu wrote:
> currently i'm the root user, but I need to execute a command as
> another user named postgres, I can do it in 2 commands, and it works
> fine.
> -----------
> su postgres
> postgres -D ~/data > ~/log/logfile 2>&1 &
> -----------
> but i hope I can do it in one command, so I tried this
> ---------------
> su -c "postgres -D ~/data > ~/log/logfile 2>&1 &" postgres
What error does that give?
> ----------------
> but it doesn't work. what's wrong with it? or any other command to
> realize it? thanks
The sudo command is an alternative that comes to mind.
- Chris Burkhardt
Reply to: