Mac OS X: 实用脚本程序(bash scripts)系列-10
最后更新于:2022-04-01 10:55:47
### Mac OS X: 实用脚本程序(bash scripts)系列-10
### --Preferences的几个例子
举几个通过变更Plist文件改变系统行为的例子:
### 1.1 电脑管理员可以设置需要Admin来控制Airport的功能,在Mac OS X 10.5 Leopard中首次提供。在GUI环境中很容易做到,见下图:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-19_57158f4d72e82.gif)
对应的shell:
plistbuddy -c "Add $currentSet:Network:Interface:en1:AirPort:RequireAdmin bool yes" /Library/Preferences/SystemConfiguration/preferences.plist
### 1.2 Snow Leopard中的设置:
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-19_57158f4d9ff00.gif)
对应的shell:
plistbuddy -c "Add $currentSet:Network:Interface:en1:AirPort:RequireAdminPowerToggle bool yes" /Library/Preferences/SystemConfiguration/preferences.plist
### 2. 禁止用户打开Finder的Preferences的shell:
defaults write com.apple.finder ProhibitFinderPreferences -bool YES
### 3. 禁止Finder在Sidebar中显示Shared的机器列表:
plistbuddy -c "set :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.backToMyMacEnabled no"
plistbuddy -c "set :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.bonjourEnabled no"
plistbuddy -c "set :networkbrowser:CustomListProperties:com.apple.NetworkBrowser.connectedEnabled no"
### 4. 禁止自动更新
4. 1 禁止Mac OS X系统自动更新:
softwareupdate --schedule off
4.2 禁止MS Office 2004自动更新:
defaults write com.microsoft.autoupdate HowToCheck -string "Manual"
4.3 禁止MS Office 2008自动更新:
defaults write com.microsoft.autoupdate2 HowToCheck -string "Manual"
4.4 禁止Adobe CS3自动更新
sed -i "" 's:<AutoCheck>1</AutoCheck>:<AutoCheck>0</AutoCheck>:' /
/Users/$USER/Library/Application/ Support/Adobe/Updater5/AdobeUpdaterPrefs.dat
4.5 禁止Adobe CS4自动更新
sed -i "" 's:<AutoCheck>1</AutoCheck>:<AutoCheck>0</AutoCheck>:' /
/Users/$USER/Library/Application/ Support/Adobe/Updater6/AdobeUpdaterPrefs.dat
###
### 5.迫使Safari 4在tab中打开新网页
defaults write com.apple.Safari TargetedClicksCreateTabs -bool true