mac下开机自动执行sudo命令的方法

2020-08-16  本文已影响0人  zbmzly

参考https://technology.siprep.org/running-sudo-commands-in-automator/#:~:text=If%20you%27re%20wondering%20how%20to%20run%20sudo%20%28for,over%20to%20the%20workflow%20area%20on%20the%20right.

1 打开mac中的Automator程序


截屏2020-08-16 上午10.54.57.png

2 创建一个“应用程序”


截屏2020-08-16 上午10.55.30.png

3 点击“运行AppleScript”这个action,拖动到右侧面板


sudoautomator01.png

4 输入运行sudo的命令,比如

do shell script "sudo whatevercommandyouwanttorun" with administrator privileges

如果你要运行一个脚本,运行:

do shell script "sudo /path/to/youractualscript.sh" with administrator privileges
sudoautomator02.png

5 保存这个“应用程序”


sudoautomator04.png

6 尝试打开这个应用程序,测试他的可用性。这时应该会提醒你输入密码,因为你执行了sudo命令。

7 在系统偏好设置------用户与群组------登录项中,添加刚保存的application

上一篇 下一篇

猜你喜欢

热点阅读