September 11, 2009

Command-Line Tools

There are a lot of handy command-line tools stashed around OS X that are very useful when deploying, maintaining, and supporting Macs. These are a few my favorites:

asr efficiently copies disk images onto volumes, either directly or via a multicast network stream. asr can also accurately clone volumes without the use of an intermediate disk image.
Example: $asr restore -source /Volumes/Macintosh\ HD -target /Volumes/New\ HD to clone one drive to another

hdiutil uses the DiskImages framework to manipulate disk images. Software developers should take note of the ability to set disk images as “internet-enabled”, and you can even split DMGs into multiple parts:
$ hdiutil segment -segmentSize 10m -o /tmp/aseg big.dmg

bless can set volume bootability and startup disk options, this is very handy for using in imaging scripts. Example: $ bless —mount “/Volumes/Mac OS” —setBoot sets the “Mac OS” volume as the boot drive, and $ bless —netboot —server bsdp://1.2.3.4 sets the computer to boot from the NetBoot server at 1.2.3.4.


These are a little more complex, but also can be quite useful:

airport is a utility for working with the Airport interface. It is buried at:
/System/Library/PrivateFrameworks/Apple80211.frameworkrsions/A/Resources/airport, so you may want to make a symlink to /usr/local/bin/airport or some other location.

systemsetup is used by the Setup Assistant, this tool has lots of options with very long names, so double-check for typos before you hit return.