Switch user in a init script?

前端 未结 3 448
生来不讨喜
生来不讨喜 2021-02-06 05:37

Here\'s my Init script which I have at my Ubuntu workstation. I need to run a command as another user than root, but I just can\'t get my head around how it should be done. Neit

3条回答
  •  梦毁少年i
    2021-02-06 06:01

    su is probably a more universal approach, but this is also possible on some common distributions with sudo:

    sudo -u $MUSER $COMMAND $ARGS
    

    (just reread your question and didn't realize that doesn't work for you, but it has worked for me in init scripts)

提交回复
热议问题