开发者

change user in sudo bash script

开发者 https://www.devze.com 2023-03-16 06:42 出处:网络
In a bash script that is called with sudo i am calling: /usr/bin/firef开发者_StackOverflowox -new-tab http://stackoverflow.com

In a bash script that is called with sudo i am calling:

/usr/bin/firef开发者_StackOverflowox -new-tab http://stackoverflow.com

but then i get the message:

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system

this is, i guess, because the script is called by sudo and firefox by the normal user. if i would call the command without sudo it works.

so how can i switch back to the normal user in a sudo called script?


using sudo again inside your script.

sudo -u user -H /usr/bin/firefox -new-tab http://stackoverflow.com


This post might answer your question

0

精彩评论

暂无评论...
验证码 换一张
取 消