There are many articles documenting the command line of OSX, many of these articles cover the basics that unix geeks are already familiar with, command line completion, ls and it's arguments, permissions and directories.
Few of these articles cover the Macos X specific commands that can make OSX command life easier.
osascript, is probably the most useful of all that I've come across, it allows access to apple script to control applications running on the machine, it's another scripting language but I find the language a little difficult to understand, as it's all about message passing and telling an application what to do, no telling the window of the application what to do. no wait, telling the document of the window of the application what to do. I'm not going into apple script here.
The script is entered on the command line with the -e option:
osascript -e 'tell application "eyetv" to get recordings'
hdiutil is mostly used for manipulating disk images the most useful things it can do are;
Burn CDs (from a discimage)
hdiutil burn discimage.iso
Make disk images
hdituil create -src ~/Documents documents.dmg
Mount disk images
hdiutil attach documents.dmg
diskutil is used mostly for preparing or erasing disks. Some of it's functionality seems to overlap with hdiutil but the most useful features are;
erasing and partitioning a disk
diskutil erasedisk "Journaled HFS+" MyNewDiskname disk2
Formatting a device with FAT for sharing with a windows machine:
diskutil erasedisk "MS-DOS FAT32" NEWDISK MBRFormat disk3
(FAT doesn't support case preserving volume names)
listing attached disks and partitions
diskutil list
disktool is used for mounting and unmounting disks.
Unmount a disk (not eject) useful when using unix tools that require direct access to the disk device, such as cdrdao.
disktool -u disk2
Eject a disk
disktool -e disk2
Mount a disk (when a disk has been unmounted but not ejected)
disktool -m disk2
screencapture can save the whole screen or a single window to a file.
capture the whole screen
screencapture screen.png
capture one window, selectable by the mouse (which turns into a camera)
screencapture -iW window.png
CGsession
Lock screen
/System/Library/CoreSerices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
CGSession also supports the -switchToUserID option to switch to another user, but I've never used this command.
pdisk is the partitioning utility, It's only useful for low level editing of the partition table since diskutil can batch create a partition table when erasing a disk.
pdisk needs to be run as root, to have write access to the disk block device. It has a menu system similar to fdisk under linux and isn't difficult to work out.
sudo pdisk /dev/disk0
Installer is the software installation tool that can install .pkg or .mpkg
installer -pkg CoolApp.pkg -target /
the -verbose option allows some visibility to what is being done.
Asr is the software restore tool, it can install onto a blank disk from a diskimage. The diskimage can be made with the hdiutil command where the source directory is /
asr restore --source backup.dmg --target /Volumes/NewDisk
A diskimage can also be another disk volume, for backing up one entire volume to another (like carbon copy cloner for you mac people)
asr restore --source /Volumes/OldVolume --target /Volumes/NewDisk
Once a diskimage is created it must be indexed using the asr imagescan command.
asr imagescan --source backup.dmg