Mac OS X Command Line notes

Encrypted Filesystems with Sparse Bundles
Mac OS X offers encrypted filesystems through sparse bundles.  To mount up a sparse bundle, given the password used to create the bundle, use the hdiutil:

hdiutil attach -verbose -readonly /path/to/sparse.bundle.directory

This will mount up the sparse bundle located at the directory path specified.  To unmount the sparse bundle, use:

hdiutil detach /Volume/sparse.bundle.name

Adding entries to /etc/hosts
Although simply editing /etc/hosts should work, there are times where the new entries may not be recognized, in these cases the OS X name cache daemon needs to be kicked:

dscacheutil -flushcache

Mac OS X Hostnames
Although you can change the hostname of your Mac OS X device through the System Control Panel -> Sharing, the following command line can lock the name so DHCP and other dynamic networking protocols don’t mess up your hostname (from RichardBronosky):

sudo hostname my-permanent-name

sudo scutil –set LocalHostName $(hostname)

sudo scutil –set HostName $(hostname)

Handy Command Lines
Command line short cuts:

pmset -g batt   Show battery status

launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist; sleep 1; launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist Reload syslog daemon

SHA Hash on Mac OS X
Mac OS X doesn’t have sha256sum, but does have openssl, so the following can compute a SHA256 hash:

openssl dgst -sha256 Fedora-17-x86_64-DVD.iso