macos 如何在 Mac OS X 上以 root 身份运行脚本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/74829/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run a script as root on Mac OS X?
提问by Mac
What should I type on the Mac OS X terminal to run a script as root?
我应该在 Mac OS X 终端上输入什么来以 root 身份运行脚本?
回答by dF.
回答by Rob B
Or you can access root terminal by typing sudo -s
或者您可以通过键入 sudo -s 来访问 root 终端
回答by Hymanrabbit
In order for sudo to work the way everyone suggest, you need to be in the admingroup.
为了让 sudo 按照每个人建议的方式工作,您需要加入该admin组。
回答by Bob Wintemberg
sudo ./scriptname
须藤 ./脚本名
回答by Dana
sudo ./scriptname
须藤 ./脚本名
sudo bash will basically switch you over to running a shell as root, although it's probably best to stay as su as little as possible.
sudo bash 基本上会将您切换到以 root 身份运行 shell,尽管最好尽可能少地保持 su。

