更新历史 :
2009-06-23: 添加关于祛除打印机共享的选项,并为了突出代码而改变字体和颜色。
2009-06-22: 添加有关用户组的部分(Group ID和Group)
添加说明的第4项.
变更ARD命令和说明中的MYADMIN.
说明 :
Account UID:
按照数字排序显示当前系统所有本地用户的UID:
dscl localhost list /Local/Default/Users UniqueID | awk ' {print $2} ' | sort -g
用于查找用户帐户的UniqueID
Group ID:
按照数字排序显示当前系统所有本地用户组的GID:
dscl localhost list /Local/Default/groups PrimaryGroupID | awk ' {print $2} ' | sort -g
用于查找用户组的唯一GID
Account:
生成一个管理员帐户 sysadmin, 帐户UID=498, 密码'SysAdmin", 帐户home目录/Users/sysadmin
dscl . -create /Users/sysadmin
dscl . -create /Users/sysadmin UserShell /bin/bash
dscl . -create /Users/sysadmin RealName SystemAdmin
dscl . -create /Users/sysadmin UniqueID 498
dscl . -create /Users/sysadmin PrimaryGroupID 80
dscl . -create /Users/sysadmin NFSHomeDirectory /Users/sysadmin
dscl . -passwd /Users/sysadmin "SysAdmin"
dscl . -append /Groups/admin GroupMembership sysadmin
cp -R /System/Library/User/ Template/user.template /Users/schooladmin
chown -R schooladmin /Users/schooladmin
隐 藏用户UID小于500.
Group:
生成一个用户组Family, GID=500, 组成员student
dscl . -create /groups Family
dscl . -create /groups/Family PrimaryGroupID 500
dscl . -create /Groups/Family RealName FamilyMembers
dscl . -create /groups/Family GroupMembers student
隐藏的用户组GID小于500
Account Priveledge:
设置MYADMIN帐户可以通过ARD管理本地计算机:
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users MYADMIN -privs -all -restart -agent -menu
Add Printer:
添加打印机:
lpadmin -p PRINTERNAME -E -L PRINTERLOCATION -v lpd://PRINTER_IP -P /Library/Printers/PPDs/Contents/Resources/HP/ LaserJet/ 9050.gz
注解: 将其中的全大写替换为真实环境中的值,最后根据打印机的型号制定打印机的PDDs文件.
Disable "Share this Printer" option:
祛除打印机的共享:
lpadmin -p PRINTERNAME -o printer-is-shared=false
在Mac OS X 10.5中使用上面的命令添加打印机后,打印机默认的是共享的,上面的语句就是祛除共享,当然-o选项王权可以使用在添加打印机的命令中.
Trace:
实用跟踪进程:
sudo opensnoop
比如:sudo opensnoop -avgn Safari
Details: http://theappleblog.com/2008/01/14/hidden-gems-in-leopard-opensnoop/