您的位置:首页 > 理论基础 > 计算机网络

Mac OS X 系统命令 (持续补充中

2012-05-06 11:49 429 查看
刚开始接触Mac OS X不久,对Unix也不太熟悉,记录一些容易忘记的操作。

sudo
command 不用输入密码

$echo “password”
 > ~/temp/temp.txt

$sudo -S id < ~/temp/temp.txt

注:以上两步可以解决临时sudo不用输入密码的问题,但不是长久之计。其实run一次sudo command并输入密码之后就直接记住密码啦。写文件记录的方式是为了可以脚本化所有的操作,输入一个password就可以一切搞定。

$sudo cp /etc/sudoers /etmp/sudoers

$sudo chmode 777 /temp/sudoers

$echo “%admin ALL=(ALL) NOPASSWD: ALL” >> /temp/sudoers

$sudo chmod 440 /temp/sudoers

$sudo cp /temp/sudoers /etc/sudoers

注:一定要把sudoers copy出去,直接修改sudoers为777 系统会禁止sudo操作。修改sudoers之后再执行sudo操作,系统会重新加载sudoers文件,但是权限必须是440,否则报错,sudo操作失效,也无法改sudo改sudoers的权限,死循环啦。当时遇到这种情况很郁闷,后来只能su到root后#chmod 440 /etc/sudoers解决。

List
all network services

$sudo networksetup -listallnetworkservices

An asterisk (*) denotes that a network services is disabled

Bluetooth DUN

Ethernet

FireWire

Wi-Fi

Bluetooth PAN

Get ethernet
info

$sudo networksetup -getinfo ethernet

……

Find
machine  DNS name

$nslookup 10.162.111.111

……

Set
machine host name

$scutil –set HostName “your host name”

Set
machine local host name

$scutil –set LocalHostName “your local host name”

Set
machine computer name

$scutil –set ComputerName “your computer name”

三个name的区别:

computer name 相当于一个alias 可以输入特殊字符,可以忽略它的存在

host name 在网络中使用的名字,网络中发生冲突时,有可能会被DNS自动修改(待确认)

local host name 跟host name差不多,一般两个保持统一就OK啦,没做更多实验 ,待更新。

 Turn
off auto update

$sudo softwareupdate –schedule off

Turn
off Bluetooth

$sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerSteate -int 0

Turn
off fireware

$defaults write /Library/Preferences/com.apple.alf globalstate -int 0

Disable
remote

$sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -agent -stop

当前用户的App数据
cd ~/Library/Saved\ Application\ State/


取消程序状态保存
defaults write com.apple.Safari ApplePersistenceIgnoreState YES


显示所有隐藏文件
defaults write com.apple.Finder AppleShowAllFiles YES

defaults write com.apple.Finder AppleShowAllFiles NO


Restore Mac OS X

创建一个restore盘

$mkdir /Volumes/restore

$mount -t smbfs //USER@url /Volumes/restore

restore命令

$sudo asr restore –source “/Volumes/restore/OS_X_10.7.3_US.dmg” –target “/dev/disk0s2″ — erase –noprompt –noverify

设置启动盘

$sudo bless -device “/dev/disk0s2″ -setBoot
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息