Mac OS X Cheat Sheet

Table of Contents

User Account Stuff

Changing login shell

(Works for Lion; not tested elsewhere): Just use the old BSD chsh command.

Creating a login hook

One solution, adapted from

First, create directory /Library/Local. Then, create file
/Library/Local/ containing, e.g.:


case "$#" in
        echo "No user specified!" >&2
        exit 1

if [ -f /Users/$1/ ]
    su $1 -c "/Users/$1/"

Use individual scripts in user directories.

User Interface

Focus follows mouse

The Mac is terrible at this capability. There are some workarounds, including:

Capturing the screen

Results are written to a PNG file on the Desktop

Disable the Dashboard


To turn Dashboard off:

$ defaults write mcx-disabled -boolean YES 

To turn Dashboard on:

$ defaults write mcx-disabled -boolean NO 

You have to restart the Dock after making either change for it to take

$ killall Dock 

Lock screen without logging off or waiting for screensaver

You can use this application (in your Applications/Utilities folder) to
quickly activate your screen saver from the menubar and require a
password to turn it off–even if the Security pane option isn’t enabled.
Open Keychain Access and then go to Keychain Access: Preferences. Click
on the General tab and select the Show Status in Menu Bar option. A small
lock icon will appear in your menu bar. Close the Preferences window and
quit Keychain Access. Now click the lock icon in your menubar and choose
Lock Screen to start your screen saver.

Another solution: Use Automator to assign a keyboard shortcut, as described

Creating a dock folder (a “stack”)

Just drag a folder to the dock. Note: Can’t always drag from the sidebar,
though (e.g., Applications)

Calibrating the monitor

Use System Preferences > Displays > Calibrate. Select Expert Mode.

Hiding users on login screen

sudo defaults write /Library/Preferences/ \
HiddenUsersList -array-add account1 account2 account3

Be sure to type .../, NOT
.../ The file name ends in .plist, but the
defaults utility ignores the extension. (Using the extension results in
creation of file /Library/Preferences/,
which is no help at all.

Creating a custom icon for a drive or folder

NOTE: Icns2Rsrc seems to be gone. For Lion, though, just try this:

Prevent Mac from going to sleep

Use Caffeine, which sits in the menu bar:

Disable “Empty Trash” confirmation dialog

Go to Finder > Preferences, select the Advanced button, and uncheck
“Show warning before emptying the Trash.” You may also wish to check the
“Empty Trash securely” while you’re there.

Change file associations

To change default application that opens a file (e.g., PDF):

Open Source Software

Mac Ports, Fink, etc.

Skip Mac Ports and Fink. Use HomeBrew, instead.



Completely re-worked, Carbon-ized, Mac-specific version of GNU Emacs.

Mac Ports

Emacs as installed via Darwin Ports (“port”). Seems to have problems
creating a mapping from Command (or Option) to the Meta key.

Build from source

Regular GNU Emacs. See


Build first for NextStep:

$ ./configure --with-ns --without-dbus
$ make bootstrap
$ make
$ sudo make install

Next, build for X:

$ make clean
$ ./configure --with-x
$ make bootstrap
$ make
$ sudo cp src/emacs /usr/local/bin/emacs-x

Then, use a modified version of the ew front-end shell script to fire up
the appropriate one, depending on whether login is local or remote.

Note: –with-ns creates a Mac folder, which ends up being
installed in /Applications, allowing use directly from the desktop.


To capture audio going to sound driver

Use WireTap Pro:

To capture audio from specific applications

Use Audio Hijack Pro:

Control sound devices from menu bar

Use SoundSource:

Convert an M4A

First, install FAAD and LAME:

$ brew install faad2
$ brew install lame

… to a WAV

$ faad -o foo.wav foo.m4a

… to an MP3

$ faad -o - foo.m4a | lame -h -b 192 - foo.mp3

Or, just install this script, as m4a2mp3:


for i in "$@"
    case $i in
            faad -o - "$i" | lame -h -b 192 - "${i%m4a}mp3"
            echo "Skipping non-M4A file $i" >&2


Capturing Streaming Video





If it hangs, try removing all the “.msf” folders in the local folders area,
letting T-bird rebuild them (especially if they were built by T-bird
running on another OS).


LPD printer stopped. No explanation

Solution: Check /etc/hosts.lpd on machine running LPD.

Change printer info

Use /Applications/Utilities/Printer Setup Utility

Disks, Files and File Systems

Encrypted file systems

Can use Apple’s FileVault. However, it encrypts the entire home directory.
To encrypt only one directory tree, use one of these options:

If your computer were stolen, the thief would be able to read any of your
files. Requiring a password to log in wouldn’t keep your data safe,
because someone could use an OS X Install disc to reset your password, or
remove your hard drive and view the files on another computer. Encrypting
your most sensitive files is the best solution.

FileVault, introduced in OS X 10.3 (Panther), can do this, but encrypting
all your data in this way can be dangerous; even a minor disk error could
leave you unable to access any of your files. A better way is to create
an encrypted disk image.

In Disk Utility, create a new disk image (File: New: Blank Disk Image).
Then, under Encryption, choose AES-128. From the Format pop-up menu,
choose Sparse Disk Image and specify a name and location. When the
Authenticate dialog box appears, choose a password; clicking on the key
button next to the Password text box will summon Apple’s Password
Assistant, which can help you generate a secure one. (See full
instructions (; if that seems like too much
trouble, you can also create an encrypted disk image with a third-party
product such as PGP Desktop Home.)

Once you’ve created an encrypted disk image, you can use it to store any
files containing private data. Just remember that as long as the disk
image is mounted, your files are vulnerable. So be sure to log out (or at
least unmount the disk image) whenever you step away from your computer.

Those .DS_Store files

Preventing Mac OS X from creating .DS_Store files over network connections

Note: This will affect the user’s interactions with SMB/CIFS, AFP, NFS, and
WebDAV servers.

Open a terminal window and type:

$ defaults write DSDontWriteNetworkStores true

Restart the computer.

Disabling the creation of .DS_Store files on remote file servers can
cause unexpected behavior in the Finder. See

(Get Info comments aren’t properly propagated.)

Getting Finder to show hidden files

In a Terminal window, run this command:

$ defaults write AppleShowAllFiles TRUE
$ killall Finder

Burning a disc

Burning a DVD from a disk image

Burning a DVD from a disk image (.img), such as one created by iDVD:

Burning from an ISO

Creating and burning a data disc

First way:

Second way:

Create a DVD from a VIDEO_TS directory

Create a DVD from a VIDEO_TS directory (e.g., as created from iDVD’s
“Save to VIDEO_TS” capability). From

Type in this command and change the paths to suit:

$ hdiutil makehybrid -udf -udf-volume-name DVD_NAME \
  -o MY_DVD.iso /path/to/VIDEO_TS/parent/folder

Make sure that /path/to/VIDEO_TS/parent/folder is the path to the folder
containing the VIDEO_TS folder, not the VIDEO_TS folder itself. Once
the .iso file has been created, drag this to Disk Utility and hit the
Burn button.

Mac Fuse and sshfs

Install via HomeBrew:

$ brew install sshfs

Be sure to follow the instructions in this output:

$ brew info fuse4x-kext

Automounting shares and NFS partitions:

Automounting Windows shares on login

Working with PDFs

Merge two PDFs, or pages thereof

Add an image to a PDF

Note that a PDF made from an image is not searchable, so that is a drawback
to this procedure.

Server Software

Restarting a server (such as Postfix)

$ sudo launchctl stop org.postfix.master
$ sudo launchctl start org.postfix.master

Enabling Postfix

Adapted from

Edit /System/Library/LaunchDaemons/org.postfix.master.plist
add following lines before the closing </dict> tag:


Edit /etc/postfix/ as necessary.

Then, start Postfix:

$ sudo launchctl start org.postfix.master

BIND on Mac OS X


Pre-Mountain Lion

Enable “Personal Web Sharing” in the System Preferences > Sharing panel.

NOTE: When you enable personal web sharing, the system creates file
/etc/httpd/users/$USER.conf to contain the Apache \<Directory\>
entry for the user’s Sites folder. Any changes (e.g., to enable
symlinking) must be made in there, not in httpd.conf.

Mountain Lion and beyond

In /etc/httpd/users, copy Guest.conf to $USER.conf, and edit
appropriately. Then, restart Apache:

$ sudo /usr/sbin/apachectl restart

Running cron

Once the crontab file and the associated script file(s) have been created
and stored in the specified locations, you must initiate the cron process
by issuing the command:

# crontab $HOME/.crontab


Clear DNS cache

$ sudo lookupd -flushcache


mDNSResponder is responsible for Bonjour. Quote from:

Bonjour is a great service that runs in the background of your Mac to
auto-discover network resources, that is, it’s great until mDNSResponder
goes haywire. I was recently in a very creatively crafted network
environment that made Bonjour absolutely freak out and tax my CPU with a
million processes, so I opted to just disable the service temporarily.
Generally speaking you should leave Bonjour enabled since its
functionality is ubiquitously used throughout Mac OS X, but if you DO
want to disable mDNSResponder, here’s how to do it:

To disable it without screwing up regular DNS:

VPN routing

Bring up a PPTP VPN and, by default, all traffic gets routed over that
connection. Solutions:

Via Internet Connect:

  1. Pull up Internet Connect.
  2. Select the PPTP VPN.
  3. Go to the menu bar and select Connect > Options
  4. Uncheck “Send all traffic over VPN connection”

Or, use a shell script to change the routes.

Dynamic linking

Use DYLD_LIBRARY_PATH to pick up .dylib files.


Startup Items

Primer on Startup Items:


See the Safari cheat sheet.

GNU configure errors

When building GNU-based open source, configure fails with

configure fails with 'Can't determine host type'

Solution: Copy config.guess and config.sub from /usr/share/libtool to
the current directory (i.e., the directory containing the GNU
autoconf-generated configure script).

Making the Mac OS X Color Picker into an Application


Consider adding the free HexColorPicker