如何在Mac OS X上运行一个脚本?

时间:2021-05-29 01:08:25

What should I type on the Mac OS X terminal to run a script as root?

我应该在Mac OS X终端上键入什么来运行一个脚本作为根?

5 个解决方案

#1


42  

As in any unix-based environment, you can use the sudo command:

在任何基于unix的环境中,您都可以使用sudo命令:

$ sudo script-name

It will ask for your password (your own, not a separate root password).

它将请求您的密码(您自己的,而不是单独的根密码)。

#2


19  

Or you can access root terminal by typing sudo -s

或者您可以通过输入sudo -s来访问根终端。

#3


3  

In order for sudo to work the way everyone suggest, you need to be in the admin group.

为了让sudo按照每个人建议的方式工作,您需要在admin组中。

#4


2  

sudo ./scriptname

sudo。/ scriptname

#5


0  

sudo ./scriptname

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。

#1


42  

As in any unix-based environment, you can use the sudo command:

在任何基于unix的环境中,您都可以使用sudo命令:

$ sudo script-name

It will ask for your password (your own, not a separate root password).

它将请求您的密码(您自己的,而不是单独的根密码)。

#2


19  

Or you can access root terminal by typing sudo -s

或者您可以通过输入sudo -s来访问根终端。

#3


3  

In order for sudo to work the way everyone suggest, you need to be in the admin group.

为了让sudo按照每个人建议的方式工作,您需要在admin组中。

#4


2  

sudo ./scriptname

sudo。/ scriptname

#5


0  

sudo ./scriptname

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。