by Chris Seibold
Copyright © 2013 Chris Seibold. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online
editions are also available for most titles (http://my.safaribooksonline.com). For more
information, contact our corporate/institutional sales department: 800-998-9938 or
Editor: Dawn Mann
Production Editor: Holly Bauer
Proofreader: Kiel Van Horn
Indexer: Angela Howard
Cover Designer: Randy Comer
Interior Designers: Ronald Bilodeau and
Illustrator: Rebecca Demarest
Revision History for the First Edition:
See http://oreilly.com/catalog/errata.csp?isbn=9781449325589 for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks
of O’Reilly Media, Inc. Mac Hacks and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc.,
was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author
assume no responsibility for errors or omissions, or for damages resulting from the use of the
information contained herein.
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1. Before You Hack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Hack 01. Create a Great Backup
Hack 02. Create a Bootable Flash Drive
Hack 03. Partition that Drive Nondestructively
Hack 04. Get to Know Your User Account
Hack 05. Home Folder to Go
Hack 06. Fun with PLIST
Hack 07. Troubleshooting Mac OS X
2. Mountain Lion Hacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Hack 08. Copy the Mountain Lion Installer to a Flash Drive
Hack 09. Resurrect Web Sharing in Mountain Lion
Hack 10. Make Notification Center Less Annoying
Hack 11. Quick Hacks for Mountain Lion
Hack 12. A Clean Install of Mountain Lion
3. Customize Your OS X Experience . . . . . . . . . . . . . . . . . . . . . . . . . 65
Hack 13. Tame Your Browsers
Hack 14. Blog with Your Mac
Hack 15. Host a Web Page on Your Mac (and Get at Your Files Anytime)
Hack 16. Change the Startup Sound
Hack 17. Full Screen for (Almost) Any App
Hack 18. Create Custom Icons
4. Hacks for a More Informative Mac . . . . . . . . . . . . . . . . . . . . . . .
Hack 19. Quit the Finder
Hack 20. Move a Widget to the Desktop
Hack 21. Turn Your Desktop into a Fount of Useful Info
5. Make It Automatic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Hack 22. Getting Things Done with AppleScript
Hack 23. Create a Service with Automator
Hack 24. Customize the Services Menu
Hack 25. Speed Things Up with Keybindings
Hack 26. Eject iTunes
6. Fun with Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Hack 27. Harmless Unix Tricks
Hack 28. Install Homebrew
Hack 29. Get Things Done Safely with the Command Line
Hack 30. Manipulate Images with ImageMagick
Hack 31. Customize the Dock with Terminal
7. Lock Down that Mac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Hack 32. Achieve Network Anonymity
Hack 33. Monitor Your Network Traffic
Hack 34. Protect Sensitive Files
Hack 35. Encrypt a USB Drive
Hack 36. Add Physical Security Measures to Your Mac
8. Other OSes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Hack 37. Run a Minecraft Server on Your Mac
Hack 38. Play Wii Games on Your Mac
Hack 39. Manage Your Devices with Profile Manager
9. Networking Hacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Hack 40. Optimize Your WiFi
Hack 41. Secure Your Wireless Network
Hack 42. Use Your Mac as an Access Point
10. Multimedia Hacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Hack 43. Turn Your Mac into a DVR
Hack 44. Master Torrents
Hack 45. Move Your iTunes Library
Hack 46. Get Free and Better-Sounding Music for iTunes
11. Hack Some Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Hack 47. Have Your Mac Automagically Recognize You
Hack 48. Squeeze Some Speed out of an Aging MacBook Pro
Hack 49. Give Your Polycarbonate Mac a Dye Job
Hack 50. Get that iMac out of the Way
Hack 51. Use a Wiimote with Your Mac
TABLE OF CONTENTS
Hack 52. Turn Your MacBook into a Tablet
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
TABLE OF CONTENTS
Before You Hack
Hacking is fun and productive, but it can also introduce an element of danger (perhaps
that’s part of the fun). You want to minimize that danger, and the best way to minimize
the bad stuff that can happen is to back up your data and know what to do when
something goes wrong. This is why this chapter is here. You’ll discover some basic
hacking techniques but, before you try them, you’ll learn how to protect your precious
data. If something does go wrong, you’ll have the tools to fix the problem very quickly.
The interesting world of hacking awaits!
Create a Great Backup
Even if you never plan to perform a single hack in this book, you’ll still
want a reliable backup. This hack explains different methods you can use
to back up your Mac so you can be confident that you’ll be able to recover
quickly when things go wrong.
If you’re ever asked what the most important part of a computer is (and that’s a question companies sometimes ask employment seekers), you could do much worse than
saying, “A good backup.” Why not, say, the CPU or graphics card instead? Because a
good backup is where all your work, toil, pictures, movies, and other accumulated data
is preserved for that inevitable moment when everything stops working. With a good
backup, you don’t start over, you simply restore. Without a good backup, well, good
luck getting that loved one to put on a prom outfit 5 years later.
The point is that some things can’t be re-created (and even the ones that can be recreated might take an obscene amount of time and effort and, likely, still not be as
good as the original). So your goal should be to both minimize downtime and minimize
lost data—and a good backup helps you achieve both these goals.
What Makes a Good Backup?
The phrase “a good backup” gets tossed around a lot, but it’s rarely ever defined. What
is a good backup? That depends on what data you don’t care about and what data
you couldn’t stand to lose. For our purposes, “a good backup” is one that saves your
precious data and gives you peace of mind. To find the backup method that’s right for
you, we’ll look at several different options for backing up your computer.
Maybe You Don’t Need to Back Up
While backing up is a great idea if you store any critical or nonreplicable
information on your computer, there’s a chance that the amount of data
that’s stored exclusively on your computer and nowhere else is very small.
For example, if you’re a big-time photo sharer, all your pics might be on
Flickr. Or you might be a huge fan of iTunes Match, store all your documents
in iCloud, and have purchased all your apps via the App Store. If this more
or less describes you, you might not even want to hassle with a backup
because you’re generally using backups all the time. To put a finer point on
it, if your Mac were to get wiped out, all your data would still exist in the cloud
somewhere. Conversely, if the cloud were to go dark, everything’s on your
Mac. Your penchant for accessing your data everywhere has saved you the
hassle of backing up!
The most user-friendly way to back up your Mac is Time Machine (Figure 1-1), which
is built into OS X and is incredibly easy to use. The idea behind Time Machine is simple:
you hook a drive up to your Mac and Time Machine copies the drive. Once the drive is
copied, Time Machine incrementally copies any changes you make (file by file). If you
lose a file or something goes wrong, you can step backwards in time to the good old
days when everything was how you wanted it or just retrieve the file that’s missing.
Time Machine backups are good enough for most people, but if you’re going to be
hacking around on your Mac and trying stuff you wouldn’t normally try, you’ll likely
want something a little beefier. Creating a backup you can boot from (which you can’t
do with Time Machine) is a nice place to start. The next section explains how to
Time Machine’s intuitive interface. Use the timeline on the right side of the screen to scroll back in
time and retrieve the data you’re missing, or restore your Mac to how it was on a specific date.
Quick Hack: More Control over Time Machine
Unless you tell it otherwise, Time Machine backs your Mac up every hour.
You might find that to be too often or—if you’re working on important stuff
—not often enough. Fortunately, with a text editor and a little determination,
you can change that interval. Navigate to:
your hard drive/System/Library/LaunchDaemons/com.apple.backupdauto.plist
Copy that file, and then open it with a text editor. The file isn’t long so you
won’t have any problem finding the line that reads:
3600 is the number of seconds betwixt backups, so increase or decrease
that number until the interval seems ideal to you. Replace the original file
with the edited version you just created, and Time Machine will back up
according to your schedule!
Backing Up with Disk Utility
Your Mac comes with a nice utility for duplicating drives. It’s called Disk Utility and
you’ll find it, as you’d expect, in the Utilities folder (Applications/Utilities/Disk Utility).
CHAPTER 1: BEFORE YOU HACK
That takes care of the software you’ll need, but you’ll also need some media to store
your backup on. In a perfect world, you’d have a massive amount of super speedy
storage. But since this media is for backup purposes, cost considerations can be more
critical than high speed, so whatever you’re comfortable with will do. Just make sure
the drive/flash stick/ssd/partition you use is the same size or larger than the disk you
want to backup.
Attach your backup media to your Mac in the manner required by the media. (I usually
just jam the connector blindly into the back of my machine until it fits, but you might
want to use more care.) Next launch Disk Utility. Once Disk Utility is up and running,
you can get to the business of duplicating your drive. Click the Restore tab and then
drag the disk you want to copy from the sidebar into the Source field. You can guess
what’s next: drag the disk that you want the back up to into the Destination field
In this case, the partition named “the 300” is being duplicated to the partition Mac Hacks BU. OS X
treats separate partitions as different disks even though they can be on the same physical drive. This
illustration shows three physical drives and five partitions.
Click Restore and OS X displays a message asking if you’re sure you want to replace
the contents of the targeted drive. You’re careful and you’ve thought this out, so click
Erase. Once you do that, you’ll be asked for your password.
Type in your password and Disk Utility will go about the business of copying the data
to the destination drive. Unlike Time Machine, which copies drives file by file, Disk
Utility works by copying drives block by block, which yields an exact copy of the drive
and keeps it bootable. (If you use a copy method that copies file by file, the result won’t
be bootable unless you take some extra steps.) When the process is finished you’ll
have a new drive with all your old data that you can use to boot your Mac if things go
horribly awry. But before you start sloshing cola on your old drive, take a quick trip to
System Preferences and choose Startup Disk. If the backup process went smoothly,
you’ll see an option to use the drive you just cloned as a startup disk. As shown in
Figure 1-3, the name of your newest drive has been changed to match the name of the
drive you just cloned.
Use the Startup Disk preference pane to make certain that the backup disk is bootable. Note that
there are now two drives named “the 300.” You can tell them apart by their different icons: the one
on the left (the backup) is a USB drive, and the one on the right (the original) is a hard drive.
Create a Bootable Flash Drive
Your installation of OS X has recovery tools built into it. But because those
tools are stored on your hard drive, they won’t do you any good if the
thing wreaking havoc with your Mac is the drive. This hack explains how
to make a cheap startup disk using a USB stick and a free Applesupplied program.
In the olden times, back when you had to install new versions of OS X from a DVD, you
always had an emergency startup disk. Snow Leopard acting wonky? Cram that DVD
CHAPTER 1: BEFORE YOU HACK
into your iMac’s superdrive, press Option-O when it starts, and boot from the install
disk. It was a slow process but at least it got your Mac going again.
OS X Lion and Mountain Lion are different. Since they don’t have physical install disks,
the emergency boot option is installed on your drive when you install Lion or Mountain
Lion. This is called the recovery partition and it’s a tiny slice of the media you use to
boot from. This slice holds a bunch of nifty tools for you to use in an emergency (for
a more thorough discussion of the emergency boot partition, see Hack #07 ). The unfortunate thing is that none of those will do you any good if something is wrong with
What you really need is a way to create a bootable disk. Happily, Apple offers a program
to do exactly that, it just isn’t all that well known and—truth be told—once you’re
interested enough to learn about it on your own, it might be too late to solve
How do you get your own slice of USB-startup-disk heaven? Point your Mac to the
support page for OS X Recovery and click the download link on the upper right side of
the page. It’s a small file (1.1 MB) so the download will be quick. (If the link listed here
doesn’t work for you, a web search for OS X Recovery Disk Assistant will find
Recovery Disk Assistant arrives as a .dmg file. As you’d expect, double-clicking this
file will expand and give you access to the program. You can move it to your Applications folder, but you’ll likely want different versions of a recovery disk for all your different Macs, so save the app to each of your Macs.
Pro Tip: Make Separate Recovery Disks for Each
of Your Macs
If you have multiple Macs, your inclination might be to make one Recovery
USB stick, place it behind glass with a hammer attached by a chain, and use
it in the event of an emergency with any of your Macs. That plan seems solid,
but it might not work.
The general rule is that if you’ve upgraded your Mac to Lion or Mountain,
and created the recovery disk on that machine, it will work on any other Mac
you’ve upgraded in the same manner. So if you’ve got an iMac and a MacBook Pro that both shipped with Snow Leopard and you’ve upgraded both
of them to Mountain Lion, the recovery disk you created on one machine
will work on both of them. But if the iMac has been upgraded to Mountain
Lion and the MacBook is still using Lion, the recovery disk won’t work on
both computers. Things get weirder if you have a Mac that came with Lion
or Mountain Lion preinstalled. For such machines, only recovery disks made
on the same machine you’re using them for will work. Want to use a USB
recovery stick with your 2012 Retina MacBook Pro? You’d better make sure
you made it on that machine.
The easiest solution? Just make one recovery disk for each computer, on
each computer. Mark which one is which and hope you never need them.
Grab a blank USB drive that’s at least 650 MB in size that has no important data on it
(Recovery Disk Assistant erases all the data as it creates the disk). Now is a great time
to rename the USB disk to something easily recognizable. (To rename the disk, plug
it into your Mac and, when the disk’s icon appears onscreen, click the icon and then
click its name; then type the new name. This isn’t a long-term commitment: once the
process is done, you won’t see the disk at all, so don’t fret over the name.)
So your drive is plugged in, devoid of necessary data, and named something you can
spot easily. Great—the hard work is done. Launch Recovery Disk Assistant (Figure 1-4)
and let your Mac do the hard work! You’ll be asked for your password and then Recovery Disk Assistant will take a few minutes to actually write the disk.
The drive selection screen of Recovery Disk Assistant. Make your choice carefully as the selected
disk will be erased.
Once everything is in place, Recovery Disk Assistant will tell you that the process is
finished and you’ll have a disk you can use to start your Mac when things go wrong.
Since the disk is a copy (more or less) of the recovery partition built into your hard
CHAPTER 1: BEFORE YOU HACK
drive, it’ll give you access to all the same tools you’d have if you booted from the
recovery disk (Disk Utility, Terminal, etc.).
There’s a downside to this method, however: from now on, when you insert the disk
into your Mac’s USB slot, nothing shows up onscreen. That’s because that disk is
dedicated only to booting your Mac and helping you recover—you can’t use it for anything else. (There is a workaround that will make your Mac display the disk: shut down,
plug in the disk, and then hold down the Option key while you start up.) For that reason,
you probably want to boldly label the disk with the name of the machine you created
Honestly, the whole process is kind of cumbersome—creating specific disks for specific Macs (but only sometimes)—but in an emergency the disks can be real lifesavers.
Partition that Drive Nondestructively
At some point you’ll want partitions on your hard drive, but partitioning
a drive usually means erasing the data on it first. This hack reveals how
to partition your drives without losing any data.
When you get a new Mac, you’re understandably excited and you want to start using
that thing right away. You create some data, transfer some pics onto it, and now the
Mac is yours. A few weeks later you realize you’d really like to have some partitions on
your Mac. The problem is there’s no obvious way to partition the hard drive without
losing the data you’ve created.
The most obvious workaround is to back up your disk with Time Machine or clone it,
and then boot from some other disk and partition your disk. But that involves a lot of
time and hassle. What you want is a method to partition your existing disk without a
lot of work.
When you partition a drive in OS X, the operating system will treat that single
drive physical drive as multiple drives. The partitions will look like completely separate disks in the Finder and you can treat them as different disks
for everyday computing.
Partitioning your drive is useful for a variety of reasons. Partitions can help
with organization, troubleshooting, and backup planning. But there’s one
big caveat: partitions won’t help you if the hard drive dies—all the partitions
go down with it.
The coolest hacks use tools in unintended ways. This one uses Boot Camp Assistant
and a Windows install disk to create a new partition without having to erase your data.
Boot Camp Assistant is an application published by Apple that helps you install Windows on your Mac. If you’re wondering how installing Windows on a Mac relates to
partitioning your drive without losing data, the answer is simple: one of the steps Boot
Camp performs is partitioning your drive.
Note: This hack requires a Windows install disk. But it doesn’t require a never-used
install disk. I used an old Vista install disk, but you can get away with using any disk
someone has laying around. You won’t be running Windows anyway!
The good news is that Boot Camp Assistant is already on your Mac (you’ll find it the
Utilities folder), so the only thing you need to hunt down is that Windows install disk.
Once you find one, launch Boot Camp and get ready for some ominous warnings. The
first screen of Boot Camp Assistant warns you to back up your computer. Heed this
advice! Your drive is about to be messed with and, without a good backup, you could
suffer major data loss. (See Hack #01 for advice on backing up.)
Click Continue and you’ll see a few checkboxes offering to get some Windows support
files from Apple’s servers and install Windows (Figure 1-5). You’re not here to install
Windows, you just want Boot Camp Assistant to take care of a little drudgery. But if
you uncheck all the boxes, then Boot Camp Assistant won’t run. If you read the fine
print, you’ll note that the Install Windows option states that it will add a partition for
Windows, which is exactly what you want, so turn off all the checkboxes except
Once you click Continue, you’ll find the path to happy partitioning. You’ll have an option
to set partition sizes (Figure 1-6). What partition scheme you use is up to you, but the
larger the partition you select the more flexibility you’ll have in the future.
Once you’ve made your decision, insert your Windows install disk and then click Install.
Your Mac will restart and attempt to install Windows. But you aren’t after Windows,
so don’t waste time installing Windows; stop the install process by pressing the Eject
key while the Mac is rebooting to force it to use its internal drive. Your Mac will go
through the normal startup process and when it’s done, the new partition will just be
sitting there! Back to Disk Utility to format your brand-new partition in any manner
you wish (Figure 1-7).
CHAPTER 1: BEFORE YOU HACK
If you ever truly want to install Windows, the process will be different. But for the purposes of partitioning, only check the Install Windows box.
To set partition sizes, either drag the divider between the two partitions or you could opt to use the
Divide Equally button. It’s your partition—do what you want!
Here Disk Utility is being used to change the partition from MS-DOS FAT to a more Mac-friendly partition. Sure, your Mac can use disks formatted in MS-DOS FAT, but it prefers HJFS+ made specifically
with Macs in mind.
Beyond the Hack
It will likely occur to you that tricking Boot Camp Assistant is one way to partition your
hard drive, but probably an unnecessary way. After all, if Boot Camp Assistant can
nondestructively partition your disk, you can probably do it yourself. You’re right—you
can do it without Boot Camp Assistant, though you’ll need to spend some time
Note: From the department of “It can’t be said enough,” you really should back up
your drive before you try this. Is your data backed up? Good, let’s get going!
Fire up Terminal (it’s in your Utilities folder) and you’ll see a window that looks remarkably like an old-style computer terminal. If you feel a little intimidated by Terminal, check out Chapter 6 before you start; if not, it’s time to start typing. Take a deep
breath and type:
Not too hard, right? What that command does is tell your Mac to reveal all the partitions on the drives mounted on your Mac (“mounted” doesn’t necessarily mean physically mounted—it just means currently available to your machine; you can have disks
plugged in that aren’t mounted). The output will vary from machine to machine, but
CHAPTER 1: BEFORE YOU HACK
it’s generally almost humanly understandable. When I ran diskutil list on my iMac
in Knoxville, Tennessee, I got an output that looked like this:
209.7 MB disk0s1
Apple_HFS the 200
201.6 GB disk0s2
Apple_Boot Recovery HD 650.0 MB disk0s3
Apple_HFS the 300
Apple_Boot Recovery HD 650.0 MB disk0s5
Apple_HFS the 500
Apple_Boot Recovery HD 650.0 MB disk0s7
292.2 GB disk0s4
504.2 GB disk0s6
What can we learn from this output? SIZE, as you’ve guessed is the size of the disk.
IDENTIFIER is how the computer tells one disk from another, and TYPE NAME is how
you can tell what each disk is. In this particular case, we have a 1.0 TB disk (disk0) that
has been divided into seven partitions. The first partition is EFI (disk0s1), which contains some device drivers and other necessary things for your Mac to boot; you won’t
need to mess with that partition for the purposes of this hack. I created the second
partition (disk0s2) for storing movies, so we’ll leave that one alone, too. The next one
(disk0s3) is a recovery disk generated during the install of Lion or Mountain Lion. We
won’t be altering that partition in this hack either, so we can skip Apple_Boot
This brings us to the disk we want to repartition: Apple_HFS the 300 (a.k.a. disk0s4).
Before we partition the disk, we should decide what size partitions we want. To figure
that out, we need to know how much of the disk’s space is already in use (we don’t
want to lose any data, now do we?). To find that out, at the Terminal prompt, type:
The df command tells your Mac to list information based on file systems, and the –h
flag tells Terminal to list the data in human-readable form. The output will tell you more
than you really want to know so, in this case, we’ll just pay attention to the disk we’re
going to partition. Here’s the relevant information:
Used Avail Capacity iused
272Gi 68Gi 204Gi 25%
17817531 53526975 25%
Well that is almost humanly understandable! If you look closely, you can tell that the
disk known as “the 300” is 272 GB in size and that 68 GB have been used, leaving us
with 204 GB available. That’s certainly enough space to make it worth our while to
create a new partition.
Let’s see what the limits of our partitions will be using the diskutil command:
diskutil resizeVolume disk0s4 limits
Which tells us:
For device disk0s4 the 300:
Current size: 292.2 GB (292227104768 Bytes)
Minimum size: 78.3 GB (78349324288 Bytes)
Maximum size: 292.2 GB (292227104768 Bytes)
Those are the limits of what we can do; we’re free to choose any value within those
limits. In this case we’ll use 100 GB for the old disk (“the 300”) and 190 for the new
disk (which will be named, unimaginatively, “NEWPART”). To get the new partition
made, we need to use diskutil to tell the program exactly what we want to do. To do
all that, type:
diskutil resizevolume /dev/disk0s4 100G JHFS+ "NEWPART" 190G
That doesn’t make a much sense if you just look at it. Here’s what each part of that
• diskutil is the program that will be doing the work; it’s built into OS X.
• resizevolume explains what you want diskutil to do.
• /dev/disk0s4 tells diskutil which disk you want it to resize.
• 100G tells diskutil that you want the old partition reduced to 100 GBs.
• JHFS+ tells diskutil that you want the new partition to be a Journaled Hierarchical
File System Plus, which is the type of partition your Mac prefers (though you can
choose other systems if you like).
• "NEWPART" tells diskutil what to name the new partition.
• 190G tells diskutil you want the disk partition to be 190 GBs.
You’ll need to adjust the command to your specific desires. Once you get all that typed
into Terminal (careful—spelling and spacing matters), hit Return and diskutil will
start the process. You won’t see the nifty OS X progress bar that you’re familiar with;
CHAPTER 1: BEFORE YOU HACK
instead you’ll see the Terminal version of a progress bar. (What does a progress bar
look like in the Terminal? It looks like [***----], with * representing the completed
parts.) The process can take some time (don’t close that Terminal window!), but once
it’s done you’ll have all your data and a new partition! When it’s finished, diskutil will
print out a list of the disks on your Mac, which includes the new partition:
#: TYPE NAME
209.7 MB disk0s1
2: Apple_HFS the 200
201.6 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
4: Apple_HFS the 300
100.0 GB disk0s4
5: Apple_Boot Recovery HD 650.0 MB disk0s9
6: Apple_HFS NEWPART
192.1 GB disk0s10
7: Apple_HFS the 500
504.2 GB disk0s6
8: Apple_Boot Recovery HD 650.0 MB disk0s7
You’re probably wondering why the partition came out as 192.1 GB instead of 190 GB.
The reason is actually kind of interesting: the maximum partition is 292.2 GB but the
partitions requested by the Terminal command add up to 290 GB. So instead of wasting that space, diskutil adds it on to the larger partition. (What happened to the
missing .1 GB? The world may never know.)
Get to Know Your User Account
Permissions are crucial to the functioning of OS X, and a basic understanding of them will make your hacking forays not only more fruitful but
also less fearful.
You likely know that OS X is based on Unix, an operating system invented in Bell Labs
that has been around since 1969. In 1969 the idea of a personal computer was pretty
far fetched—computers were hugely expensive and computer time was very valuable.
Because of that, Unix was designed to be a multiuser system. As such, it needed a
method for deciding just what each user can do with the machine. (It would be bad if
one student could erase another student’s work or, the other extreme, a setup where
only one superuser could make any changes at all.) Permissions allow users to change
what they need to change while protecting others who use the same machine from
accidental data deletion.
When you first set up OS X, you provided a name, OS X suggested a short name which
you may or may not have chosen to use, and you were off to the races. “No big deal,”
you might think, “this is just routine housekeeping when setting up a new machine.”
Actually, this step is kind of a big deal—the first account you set up in OS X is, by
default, an administrator account.
OS offers three main types of accounts: Administrator, Standard, and Managed with
Parental Controls. (There are other types listed in the Users & Groups preference pane,
but the ones listed above are your best bets for everyday use.) Administrators have a
lot of power in OS X—they can make global changes that impact everyone who uses
that computer—so logging in as an administrator for day-to-day use isn’t the best
idea; with that much power over the entire system, you can cause serious harm to
your account and others’. It’s much better to log in as a standard user for day-to-day
tasks while reserving the administrator account for those times you need to, well,
administrate. Standard users can make changes that impact their own accounts, and
Managed users can only do what the administrator specifically allows. The Standard
account is the sweet spot because you get to control the stuff you need to control, but
you can’t mess up anyone else’s work or the machine.
The most obvious objection to switching to a standard user account is that you’re
already using one account and you don’t want to re-create everything for your new
account. That’s a valid objection—but one we can work around.
What You’re Really Changing with a Standard
Account: The Home Folder Library
A standard user on OS X has plenty of control over their information and
preferences. Preferences for each user are stored in each user’s Home folder’s Library. The Library is what makes your Mac feel like it’s yours. You
might want to directly tweak the files in your Library, but if you go poking
around in your Home folder, you won’t see anything that looks like it might
be storing your preferences and the like. That’s because those things are
stored in the Library folder and, starting in OS X Lion, Apple made that
This can be frustrating for longtime Mac users who are used to messing
around in that folder. For example, an app is giving you a ton of problems,
you might want to jump to the Library folder and delete your preferences
for that program, which can sometimes make the app more responsive (the
preferences will be regenerated).
Fortunately, Apple gives you a simple way to access your Library folder. In
the Finder’s menu bar, open the Go menu and then press the Option key.
Voilà—a Library option appears in the menu (Figure 1-8)!
CHAPTER 1: BEFORE YOU HACK
Pressing the Option key when viewing the Go menu isn’t the only way to find your Library folder, but
it’s probably the easiest.
Turning Your Administrator Account into a Standard Account
Fire up System Preferences and head to Users & Groups. You’ll see a list of users on
the left side of the pane with the current user at the very top. Immediately under each
user’s name is a label that indicates what kind of user they are (Figure 1-9).
If you only have one administrator account, you can’t really change your account status because your Mac has to have at least one admin-level user. In that case, the first
step is to add another administrator user. Click the lock icon in the pane’s lower-left
corner and then type in your administrator password in the window that appears. Once
the pane is unlocked, you can add a new account. Click the + button above the lock
icon and a new window will appear (Figure 1-10).
Fill out the fields and pick a good password (click the key icon if you want Password
Assistant to help you pick a secure one); write yourself a meaningful hint and click
Create User. You now have two administrator accounts. Now you’re ready to make
your original admin account into a standard account: click your original account in the
list on the right side of the preference pane, and then uncheck the box that says “Allow
user to administer this computer” (Figure 1-11). That’s it—you’ve turned your overly
powerful administrator account into a safe-to-use-daily standard account! (Well, after
you restart your machine, anyway.) In Figure 1-11, a former administrator account has
become a standard account.
You can do a lot more with this pane than just add users. Click the Login Items tab if you want programs to start automatically when you log in.
You might be experiencing some regret at this point. What about all the power you
gave up? How will you get things done when you need to be an administrator to accomplish something? Will you have to log out and log back in? Don’t fret: everything
will be almost exactly the same. You’ll still have all the same powers, you’ll just have
to occasionally enter the admin username and password you just created instead of
the password associated with your now-standard account—a small price to pay for
CHAPTER 1: BEFORE YOU HACK
Adding a new Administrator to your Mac. This one won’t be for day-to-day use; instead, you’ll use it
on those special occasions when you want to boss your computer around for a bit.
Behold your new standard user account. Finally, everyone can sleep soundly at night.
Enabling the Root User
Now you know the safe way to do things when it comes to user accounts, but that
method might not be to your liking. You might be one of those folks who wants to
control everything—you’re so certain of your abilities that you don’t want to stumble
along using a standard account to safeguard other users’ data or the integrity of your
machine. If you’re one of those people, the root account may be for you.
Warning: Enabling a root account is a bad idea—a really bad idea. Don’t do it. You
can accomplish anything you want to by just being an administrator user or authenticating when you’re trying to do something potentially damaging. But if you
still insist on being lord of the realm, this section explains what to do.
You’ve been warned, but if you want to go ahead and enable the root account anyway,
the process is simple. Open the Users & Groups preference pane, click the lock icon
and enter your admin credentials, and then click Login Options. In the pane’s list of
settings, click the Join button. Doing so will display a pane where you can enter a server
for your Mac to look at. You don’t need to worry about which server to choose. Just
click the Open Directory Utility button and marvel at the Directory Utility window
Active Directory, LDAPv3, NIS—is this some sort of repository for bad acronyms? Nope. Even though
this window might not make any sense at all in light of what you’re trying to do, this is exactly where
you want to be.
CHAPTER 1: BEFORE YOU HACK
You are about to become the supreme overlord of your Mac. First, unlock the pane by
clicking the lock icon and authenticating. Next, head to the top of your screen, click
Edit, and then select Enable Root User, You’ll see some fields you can use to create a
password for the newly enabled root user. Enter the password and bang—you’ve got
a root user for your Mac!
To log in as the root user, log out or switch users. You’ll see an option on the Login
screen named Others. Choose this option and then type in root for the login name and
the password you created for that account.
Once you’re logged in as the root user, you can do anything you want. You can look at
any file on your machine (even other people’s) delete any directory, delete any file, or
completely ruin the system on a whim. Logging in as root isn’t necessarily dangerous
if you’re very careful with what you do while you’re logged in, but a moment’s lapse of
attention and you can do serious damage.
Note: If you don’t administer the Mac you use, you might be worried that the administrator could log in as root and see all your personal files. That’s certainly
possible. The way to prevent that is to move your home directory to a portable
media you can physically control (see Hack #35 ) or encrypt the data using FileVault
2 ( Hack #34 ).
Home Folder to Go
Most (but not all) of the information that makes your Mac seem uniquely
yours resides in your Home folder. Discover how to take this folder with
you everywhere you go so that any Mac feels (almost) like home.
Take the case of the mysterious Mac Guy A. He had a problem: he was constantly
using different Macs. He might use one of 20 different Macs in his school’s computer
lab, give a lecture using yet another Mac or, even worse, he might find himself in front
of his girlfriend’s laptop for an extended period of time.
“No big deal,” you argue, “he can use iCloud. Store his documents there and he can
access them everywhere.” A seemingly sure solution—until the network gets iffy (like
it is at more than one place he visits) or he runs up against his data limit (iCloud storage
So the problem remains. He doesn’t want to haul his Mac Pro around in a heavy-duty
backpack (plus think how long the extension cord would have to be!), he can’t use his
iPad for all his computing needs, and carrying both the iPad and a laptop seems overly
burdensome. He does have one thing going for him: he’s around a lot Macs, a lot of
the time. If he could just make all those Macs his, he would be in computing nirvana!
The good news is that you can make any Mac you meet yours. The bad news? You’ll
need some portable storage—something with more space than your current Home
folder but that’s easy to carry around. This could be an SSD drive, a high-speed flash
drive connected to your keychain, etc. Whatever you’re comfortable carrying that is
of sufficient size will fit the bill.
How Much Storage Do You Need?
To decide how big of a chip or drive you need to take your preferences anywhere you go, first find out how big your Home folder is. In a Finder window,
select Go→Computer (or press Shift-Command-C); then, select your startup drive and double-click the Users folder (Figure 1-13).
Inside the Users folder, click your specific user folder. Then see how much
space the Home folder currently demands by selecting File→Get Info (or
pressing Command-I). The size of your user folder appears right near the
top of the Get Info window. Base your purchase decision on this number. If
the amount of data seems overly large, you can selectively leave out folders
like Photos, Music, and Movies (the usual culprits).
Discovering the Home folder using the column view layout in the Finder.
What Your Home Folder Means to You
Your Home folder houses everything that you like and have customized about your
Mac: your music, your photos, and the veritable morass of preferences that tell your
applications just how you like them to behave.
CHAPTER 1: BEFORE YOU HACK
Warning: Your Home folder is crucially important—it’s one collection of files you
really, really don’t want to lose. So before you try this hack (or any potentially dangerous hack) make sure your Home folder is safely backed up. (See Hack #01 for
tips on backing up.)
Of course, not everything travels with your Home folder. Your Application folder houses
the applications you use and they won’t go for the ride unless you manually copy them
to a folder on the memory stick you’re using. You’ve got two choices: either make sure
the applications you want to use are on the Macs you’ll be using, or take your unusual
applications with you.
Turns out there’s an Application folder right in your Home folder. Usually this is reserved for apps that are installed for a single user, but there’s no reason you can’t copy
the apps you want to travel with to this folder. It won’t work for every app, but most
apps don’t mind travelling like this.
Not every application is a good traveler. While most OS X applications enjoy
drag-and-drop functionality, some very important applications do not. Mail
and Safari are two examples; they store preference files in your System
Library, so even if you copy Mail to your portable Home folder, you won’t be
able to fire up Mail and use it as though you were on your main machine.
But all is not lost: a bevy of portable versions of popular Mac apps are
available from Sourceforge. See this list of OS X portable applications to
Setting Up Your Portable Drive
The first obstacle to deal with is the fact that your drive/chip/whatever you’re using
probably didn’t come formatted with Macs in mind. Your Mac prefers a Mac OS Extended Journaled format. So fire up Disk Utility (Applications→Utilities→Disk Utility),
select the device in the lefthand column (Figure 1-14), and then click Erase and let Disk
Utility do the hard work. When it’s done, you’ll have a blank drive ready to hold your
Changing the factory settings to an OS X–preferred format.
Transferring your user account
Using Macs is easy, right? So slapping your Home folder on another drive is as simple
as a dragging and dropping it, right? Well it is—with one caveat: turns out that a Mac
needs to know where to look for your Home folder in order to use it, and telling a Mac
where to look for your Home folder isn’t a trivial task. First, you have a decision to
make: do you want the portable media to house your current Home folder and rely
solely on said media for all your Home-folder storage needs, or do you want your media
to contain a copy of your Home folder? There’s no right answer here: if you’re going
to spend a lot more time at your home computer consider using a copy; if your time
is equally spent between machines, consider using the portable media as your standalone Home folder. The difference isn’t huge, but it also isn’t negligible. Depending on
the steps you take, you can create a Home folder you use all the time (on your main
machine and all the other Macs you use) or one that you’ll use only when you’re on a
Mac that’s not yours.
Whether you’ve decided to go with a new Home folder or just go portable media all
the time, the process is the same. First, locate the Home folder you want to use on the
go and copy it to the media you are going to use. This will duplicate the data from the
CHAPTER 1: BEFORE YOU HACK
chosen folder to your destination (you’ll be asked to authenticate during the process).
Don’t worry, copying data is nondestructive, so you won’t lose any data doing this.
Note: If you decide to copy the contents of your Home folder one folder at a time,
you’ll miss the Library folder because it’s invisible. To temporarily make invisibles
visible, open Terminal and type:
defaults write com.apple.finder AppleShowAllFiles TRUE
And then press Return. This command tells the Finder to show the hidden files.
This command restarts the Finder. Now you can see the Library folder and copy it
over to your portable media. Once you’re done, head back to Terminal and type:
defaults write com.apple.finder AppleShowAllFiles FALSE
This re-hides the Library folder and other invisibles. Finally, type:
This restarts the Finder and makes everything normal again.
Quick Tip: Where Is that Users Folder?
The Users folder is located at the root of your computer’s directory, which
is a geeky way of saying that the Users folder can be found by selecting
Go→Computer from the Finder’s menu bar (or pressing Shift-CommandC). Inside the Users folder are folders for each account on your machine.
Your active Home folder—also called your User folder—looks like a house;
all the rest look like folders (Figure 1-15).
Once you have the Home folder copied to your chosen destination, you’ve got to tell
the Mac you’re using as your main machine where to look for the Home folder. Yeah,
your computer is smart, but it isn’t psychic (though Google might be).
The deliciously easy procedure to tell your Mac where your new Home folder resides?
Head over to the Accounts preference pane (System Preferences→Users & Groups),
click on the lock to make changes and then authenticate. Once authenticated you’ll
need to explore the Advanced options, which Apple has cleverly hidden from view. To
get to them, in the lefthand column, right-click the account you want to change, and
an Advanced Options item will magically appear (Figure 1-16).
The contents of the Users folder. Note that the current Home folder (also called the User folder) has
a little house icon. The contents of that folder are what we are going mobile with—it’s what makes
your Mac seem like your Mac.
Accessing the Advanced Options of the Users & Groups pane.
CHAPTER 1: BEFORE YOU HACK
Once you’ve accessed the Advanced Options pane, you’ll see a scary warning message. Don’t worry, what we’re doing won’t hurt anything. Look for the Choose button
next to the “Home directory” field. Simply click that button and navigate to where your
new Home folder resides (Figure 1-17).
Now OS X knows to look on your media for your Home folder.
As mentioned earlier, Macs aren’t psychic. So you’ll have to run through this process
on each Mac you’re planning to use.
Two Home folders or a Home folder to go?
So you want your Home folder to go but you don’t always want to rely on your portable
drive for your Home folder. In other words, you want your Home folder on your keychain when you’re away but when you’re in your dorm or apartment you want your
Mac to rely on the internal hard drive. That configuration makes a lot of sense—why
not use the built-in hard drive when you’re using your home computer?
Of course, if the latest files aren’t at your fingertips, that defeats the purpose of having
a portable Home folder (convenience). For example, if you modified a Final Cut Pro
movie while you were working on a Mac using your portable drive as the Home folder,
when you want to work on the same presentation at home, you won’t want to manually
dig through your USB drive to find the latest version.
What you need is a way to keep the Home folder on your portable media synced up
with the Home folder on your main Mac. There are many ways to get this done, either
using a command line and something like rsync or a third-party application. There’s
no single “right” method for keeping the folders synced, but one of the easiest is
Keeping everything synced
You could start from scratch and create your very own Automator workflow (see Hack
#23 for instructions), but why reinvent the wheel when someone else has done most
of the legwork? On your home Mac, point your browser to the Sync Folders download
page to grab a copy of it. Sync Folders is a very handy Automator action written by
Ben Long that can take the contents of two folders and make sure the folders exactly
mirror each other while ensuring the newest version of each file overwrites the older
files. Once you’ve downloaded the Sync Folders action, double-click the file and a
window will pop up asking if you want to install the “Sync Folders” action. Of course
you do, so click Install.
Sync Folders then needs to know what you want synced (in this case, the two versions
of your Home folder), and that we want the folder synced both ways with the newest
version of each file in both folders. The first thing to do is drag your Mac’s Home folder
from a Finder window (just grab it in the sidebar) into Automator’s workflow pane (the
upper-right pane). Then do the same with the Home folder you’ve created on your
portable storage. Make sure the pop-up menu next to Pass On is set to Both Folders,
and you’re ready to try it out. Click the Play button and witness the results of the
You probably don’t want to fire up Automator every time you want to sync your
portable Home folder and the Home folder on your main machine. No problem: one
of the great things about Automator is that it lets you save a workflow as an application
so you can just launch the application instead of mucking about with Automator. To
save Sync Folders as an application, choose File→Save As (you may have to press the
Option key to make this menu item appear), name the workflow something meaningful, and choose Application in the File Format menu (Figure 1-18); then click Save. Once
the file is saved you can sync the two folders anytime simply by launching your
CHAPTER 1: BEFORE YOU HACK
Depending on how you want to use it, you can save an Automator action as a workflow or as an application.
Using Your Home Folder on the Go
Using your newly portable Home folder is simply a matter of reversing the steps for
creating your new Home folder. Simply create a new account on the target machine
with the same name as the account on your portable media and you’re ready to go.
Once you’ve created that account, head to the Users & Groups preference pane’s
Advanced Options and point OS X to the portable media–based Home folder.
Fun with PLIST
PLIST files are strewn all over your Mac, but chances are you never see
them. That’s too bad, because PLIST files offer one of the most direct
ways to hack your machine. Spend a few moments with this hack to discover techniques for mastering PLIST files.
PLIST is short for “property list,” and these files are the main method OS X (and some
other operating systems) use to organize data so that it’s accessible by programs;
they’re also structured enough that you can generate your own PLIST files if need be.
That very brief explanation doesn’t really tell you much, but the full explanation of
what PLIST files actually do is a little dense. (If you’re really interested in the functionality of PLIST files, check out its manual entry or type man plist into Terminal.)
PLIST Files for Hackers
When you are bending your machine to your will, the most frequent PLIST files you’ll
be mucking with are the ones that store the default values of parameters for various
programs. These can range from default colors to default behaviors. These files are
typically found in the Library→Preferences folder of your Home directory (to view
them, in the Finder, use the Go menu, press and hold the Option key, and choose the
Library folder that appears; then open the Preferences folder). Tweaking these files
can yield unexpected behaviors that are mostly harmless. If you screw one up, you
can always just drag the PLIST file to the trash, and your Mac will generate a new one.
The downside of doing so is that you’ll lose your preferences for that program, so the
better way (as with all hacks) is to back up the file so you’ll have a ready-made
There’s more than one way to access PLIST files. The quickest is Terminal, via the
default command. An example will help.
Some programs can be made to display a Debug menu (most can’t), and Disk Utility
is one of these. Turns out that the Debug menu in Disk Utility is actually very useful in
Mountain Lion because it includes an option to show all the partitions on your Mac’s
drives. Why is this useful? Lion and Mountain Lion rely on a hidden partition not normally shown in Disk Utility, and it’s a partition you could accidentally delete. Knowing
whether the partition is there offers some peace of mind. Time to add the Debug menu
so you can check for the partition:
1. Quit Disk Utility if it’s running.
2. Fire up Terminal (Applications→Utilities→Terminal).
3. At the $ prompt, type this:
defaults write com.apple.DiskUtility DUDebugMenuEnabled 1
4. Launch Disk Utility.
Like magic, Disk Utility has a brand new Debug menu (see Figure 1-19). To see all your
partitions, choose “Show every partition.” If you see Recovery Disk in the list on the
left side of the Disk Utility window, you know you’ve still got the extra partition used
by Lion and Mountain Lion.
CHAPTER 1: BEFORE YOU HACK
Disk Utility’s Debug menu. You might not have seen it before, but it can be very useful.
Using Terminal is great when you know specifically what you want to change, but not
so useful if you just want to know what you can change. To find that out, you need the
property list file itself. As mentioned earlier in this section, you’ll usually find the PLIST
files you want to hack in the Library folder of your Home directory.
To open PLIST files, you need a property list editor. If you don’t have a property list
editor lying about (and you probably don’t), you’ll want to get one. In older versions
of OS X (Snow Leopard and earlier), a property list editor was bundled with Developer
Tools as a standalone application. In later versions of OS X (Lion and newer) you can
use Xcode, which is free to download from the Mac App Store. (You don’t have to use
Xcode—there are a lot of other programs you can use to edit PLIST files—but it’s hard
to beat Xcode’s price.) Once you’ve got a PLIST editor you can live with, find the Disk
Utility PLIST file we played with earlier (~/Library/Preferences/com.apple.DiskUtility.plist) and open it up (Figure 1-20).
Using Xcode to poke around Disk Utility’s PLIST file. You can make a ton of reversible choices here,
so don’t be afraid to play! Your options might look different than the ones pictured here; that’s to be
expected, because the PLIST options change as you deviate from the standard configuration.
Note: If you’re wondering what ~ (tilde) is doing in the commands for Terminal,
you’re not alone. It’s a shortcut that means Home. So instead of typing Hard Drive/
Library/Users/cks (for example), you can simply type ~ and the Terminal will know
what you mean.
You can change any of the lines you see when the file is opened. Most of the them
won’t mean much to you, but some have obvious functionality. For example, by fiddling
with DRBurnOptionsVerifyBurn (toggling YES and NO) you can stop OS X from verifying a disk after you burn it. (This is also a great example of why the PLISTs are different from Mac to Mac: if you’ve never burned a disk, this option won’t be on in your
PLIST because your Mac has never been faced with that decision.)
CHAPTER 1: BEFORE YOU HACK
So now you know how to tweak PLIST files with the command-line and a program.
Most people would say that’s enough, but if you’re messing with these files a lot, you
might want to use something more familiar. It turns out you can also touch up PLIST
files with a text editor, but it will take just a wee bit of work.
PLIST files are stored in binary format, so you’ll have to convert them to something a
text editor can read. The easiest way to do so? Terminal. Since we’ve abused Disk
Utility’s PLIST file enough for now, try poking around with Safari’s PLIST file instead
(~/Library/Preferences/com.apple.Safari.plist). Since it’s smart to work with a copy,
right-click the file and choose Duplicate from the contextual menu. Then launch Terminal and convert the file with the command line by typing:
plutil -convert xml1 ~/Library/Preferences/com.apple.Safari\ copy.plist
Here, the plutil command invokes the property list utility, -convert xml1 (that’s the
letters X, M, and L followed by the number 1) tells plutil to convert the property list
to XML, and the rest is just the path to the file. Once the command has run, navigate
to the converted file with Finder, right-click it and choose Open With→Other, and then
pick TextEdit. The formerly unreadable PLIST is now easily understandable (see
The same PLIST file side by side. The one on the left is the converted version (so it’s comprehensible). The one on the right is the unconverted version, which looks like it was created by an explosion
at a keyboard factory.
You can now edit the PLIST file however you like with TextEdit. When you’re done, you’ll
have to convert the file back to binary format:
plutil -convert binary ~/Library/Preferences/com.apple.Safari\ copy.plist
Then simply rename the file to remove the word “copy” from its name, and Safari will
happily use your handcrafted PLIST until you tire of it.
There’s much more to learn about PLIST files, but these tidbits should get you comfortable enough to start PLIST-hacking adventures and let you know what’s going on
when these types of files get abused throughout the rest of this book.
Troubleshooting Mac OS X
When you’ve been tweaking your Mac and something goes wrong, the
natural thing is to imagine your actions just destroyed OS X. That’s probably not the case—your Mac was probably going to let you down no matter what you did (hardware failures usually aren’t the user’s fault), so
don’t feel guilty. No matter the cause, the important thing to know is what
to do next—and that’s when this hack comes in handy.
OS X is a robust operating system, but while problems are rare, they do show up from
time to time. Since these issues always seem to present themselves at the worst possible moment, it helps if you know the best ways to troubleshoot them, and that’s a
great reason to keep this book around!
There are a lot of things that can go wrong with your Mac: hardware problems, software
glitches, and configuration issues can happen at any moment. Most of the problems
you’ll encounter can be easily addressed or diagnosed by following the steps in this
hack. If the information here doesn’t resolve things, it could be a unique issue, in which
case a trip to the Apple Store or a call to Apple is in order.
Tip: A complete list of Apple’s technical support numbers is available. In the U.S.,
One of the most common problems on a Mac is an application that isn’t behaving as
expected. This problem comes in many forms: an application that unexpectedly quits
repeatedly, simply stops responding, or just doesn’t perform the way it normally does.
This section suggests ways to resolve all these issues and more.
An application stops responding
Occasionally, an application will simply stop reacting to anything. Your mouse or
trackpad will still work, other programs will be fine, but if you try to use the troublesome
program, all you’ll get is a spinning beach ball cursor (instead of the mouse pointer)
and you’ll have no way to input anything.
Don’t panic—there’s an easy fix. Simply right-click or Control-click the stalled application’s icon in the Dock to bring up its Dock menu (Figure 1-22). If you see “Application
Not Responding” in faint text at the top of the menu, you’ll also see a Force Quit option.
Select Force Quit and OS X will kill the program.
CHAPTER 1: BEFORE YOU HACK
When an application isn’t playing nicely, Force Quit is your best option.
You may also need another one way to kill applications, because occasionally a program can become unresponsive without OS X realizing it. For these times, launch the
Force Quit Applications dialog box either by heading to the Apple menu and selecting
Force Quit or using the key combo Option-Command-Esc. You can also try holding
down Shift as you click the Apple menu, and then select Force Quit application
name to kill the front-most application.
There’s some good news when it comes to force quitting applications in Lion and
Mountain Lion. In previous versions of OS X, any changes you made between the last
time you saved a document and the moment the application started misbehaving
were gone forever. But these newer versions of OS X include Auto Save, which automatically saves your work as you go. So if you’re forced to quit an application, OS X
preserves the work you’ve done since the last time you saved.
Warning: For the time being “Save early, save often” is still good advice, since OS
X’s Auto Save feature only works with applications specifically built with Auto Save
in mind. That means that work you do in apps designed for Lion and Mountain Lion
will be saved, but applications that haven’t been updated for those versions of OS
X won’t automatically save your work.
The Finder stops responding
The Finder is just another program, so it can get hung up, too. If that happens, either
head to the Apple menu and choose Force Quit or use the key combination OptionCommand-Esc. If nothing happens, try clicking the Dock or some other application
first, and then use the Apple menu or Option-Command-Esc to invoke the Force Quit
Note: When you select an application in the Force Quit dialog box, the dialog box’s
button reads “Force Quit.” However, if you select the Finder, the button reads “Relaunch” instead. Why the change in nomenclature? Unlike every other application,
the Finder will be restarted immediately after it’s forced to quit.
Force quitting greedy processes
If you suspect something is eating up too much processor time or too many system
resources (because your Mac is running really slowly, say, or the fans are running at
full speed for no obvious reason), Force Quit won’t help you figure out which application is hogging all the resources. Instead, open Activity Monitor (Applications→Utilities→Activity Monitor), click its CPU tab, and then check the % CPU column for any
processes that are using a lot of CPU resources for more than a few seconds. (Safari
and its helper applications occasionally do this, particularly with runaway Flash or
name and then click Activity Monitor’s big red Quit Process button (you can’t miss it—
it’s shaped like a stop sign).
Warning: Be careful which applications you quit in this way. There are some programs that your Mac runs in the background, and many of these are important in
helping your computer operate normally. Here’s a rule of thumb: if you don’t recognize the name of the program as an application that you launched, don’t kill it.
Instead, do a Google search on its name (for good measure, include the terms “Mac
OS X” and “cpu,” too). Chances are good you’ll find a solution for whatever is causing that process to use up so much CPU time.
A misbehaving application is bad enough, but a Mac that won’t start properly is truly
disconcerting. The good news is that most such problems are usually repairable. The
general method of attack in this case is to get your Mac to a state where you can run
Disk Utility and repair the drive. However, there are some situations where you can’t
even get to that point. This section discusses your options.
Your Mac beeps at you instead of starting
If your Mac just beeps when you try to start it up, it’s trying to tell you something: one
beep means there’s no memory (RAM) installed, and three beeps means your RAM
doesn’t pass integrity check. (This goes for Intel Macs only; Power PC Macs have
slightly different beeps, but they can’t run Lion or Mountain Lion.) The problem could
be a bad RAM module, so you’ll need to open up your Mac and replace the module.
CHAPTER 1: BEFORE YOU HACK
Try installing some memory that you’re certain is fully functional to see if that resolves
the problem. If you don’t have any spare memory lying around, try removing each
RAM module and replacing them one by one until you’ve isolated the bad module.
Tip: If you don’t know how to replace memory in your Mac, check the user guide
that came with it. Or if your Mac is still under warranty, just bring it into an Apple
Store for service.
Your hard drive is making noises
If you suspect you’ve got a physical hard drive problem, you need to check things out
quickly before they get much, much worse. If you hear a strange noise coming from
your machine, that’s an obvious sign of a hard drive problem; but they can also be
indicated by the computer stalling for several seconds at a time (or making a clicking
sound when stalling).
Just as with a car, when a bad sound is emanating from your hard drive, it’s usually a
bad thing. If you’ve ever listened to the National Public Radio show Car Talk, you know
that one of the highlights is when callers try to imitate the sounds their cars are making. If you’re inclined to try identifying the sound by ear, head over to http://data
cent.com/hard_drive_sounds.php and take a listen to the sounds of dying drives, sorted by manufacturer.
Warning: If your hard drive is failing, you’re likely to lose more data every moment
it’s running. If you don’t have current backups, your best bet is to replace the drive
immediately, and either seek a data-recovery professional or, if you don’t have the
money for that, install the damaged drive in an external drive enclosure and use
the GNU ddrescue utility (www.gnu.org/software/ddrescue) to recover the data
on the damaged drive.
If you aren’t hearing any unusual sounds but still suspect your hard drive is causing
your problems, head to Disk Utility (Applications→Utilities→Disk Utility) and check the
S.M.A.R.T. status of the drive.
Using a computer means loving acronyms, and this time the acronym is clever, if a
little forced: S.M.A.R.T. stands for Self-Monitoring Analysis and Reporting Technology.
The idea behind S.M.A.R.T. is that many hard disk failures are predictable, and computer users, if given a heads-up that their hard drive is on the verge of failing, will be
able to recover data before the failure actually happens. You can discover your drive’s
S.M.A.R.T status by opening Disk Utility and selecting the disk you’re worried about
in the list on the left. In the lower-right part of the Disk Utility window, you’ll see the
S.M.A.R.T Status (Figure 1-23): either Verified (everything is fine) or “About to Fail.” If
you get the “About to Fail” notice, don’t waste any time: if your Mac is under warranty,
take it into an Apple Store; otherwise, back up your data as soon as possible (see Hack
#01 ) and start pricing out the cost of a new drive.
Note: S.M.A.R.T. status isn’t available for every drive. External drives that support
S.M.A.R.T. don’t have a way to report that over USB or FireWire, so if you don’t see
the status of a particular drive, don’t panic.
This drive is fine.
Warning: S.M.A.R.T. isn’t perfect (that’s no surprise—nothing is). You can have a
problematic drive that S.M.A.R.T. won’t recognize. So if you’re having consistent
problems and S.M.A.R.T. keeps telling you everything is fine, don’t discount the
drive as the source of the problems after you’ve exhausted other fixes.
Thankfully, the hardware failures just described are relatively rare. Much more common are software failures. Corrupt files, wonky login items, and even font problems
can cause a startup failure. These issues are generally repairable, hopefully without
data loss. Unfortunately, when you have one of these problems, the cause isn’t
CHAPTER 1: BEFORE YOU HACK
immediately obvious. When faced with a Mac that won’t boot, there are a few things
you can try to get your computer back to a usable state:
Restart your Mac
A lot happens when OS X starts up: it checks your Mac’s hardware, prepares the
system software, and more. During the startup process, there are ample opportunities for something to go wrong, especially right after you install an update to
OS X or even an application. If your Mac won’t complete the startup sequence,
don’t panic; simply restart the machine by holding down the power button until
you hear a chime; chances are everything will be fine.
Warning: If you see a flashing question mark when you try to start your Mac,
it means that your machine can’t find its startup disk. In that case, skip down
this list to “Restart in Recovery Mode.”
If a simple restart doesn’t do the trick, it means you have problems that persist
across restarts, so the next step is a Safe Boot. In Safe Mode, all your Mac’s startup items are disabled, font caches are cleared, and some other possibly problematic items are avoided. More important, Safe Boot gives you a chance to run
Disk Utility, uninstall any software that may be misbehaving, or back up your data
before whatever is causing the problem gets worse. To get your Mac to boot into
Safe Mode, hold down the Shift key after you hear the startup chime and release
the key when you see the spinning wheel appear. Once your Mac has booted, run
Disk Utility (Applications→Utilities→Disk Utility).
Note: When you’re booting in Safe Mode, the Login window automatically appears even if you usually use Automatic Login on your Mac. Don’t be alarmed
by the change—it’s a sign that Safe Mode is working as expected.
Restart in Recovery Mode
Before Lion and Mountain Lion, one remedy to try when your Mac went bad was
to boot from the DVD you either got with your Mac or purchased when you upgraded to Snow Leopard. But since you don’t use any physical media—DVD or
otherwise—when you install Lion or Mountain Lion, this trick won’t work
anymore. Fortunately, Apple realizes that, when problems occur, you might need
to boot your Mac from a different source than usual, so OS X now includes Recovery Mode.
Note: You need to be connected to the Internet to use Recovery Mode to reinstall Lion or Mountain Lion. The reinstall option will download every byte of
the OS X installer, so you might want to try other fixes before going through
with the entire process.
Recovery Mode allows you to boot from a virtual partition called Recovery HD.
When you boot into Recovery Mode, you’ll find yourself running a special system
that lets you restore your Mac from a Time Machine backup, reinstall OS X, use
Safari to look for solutions to your problem online, or run Disk Utility. (Don’t be
afraid to launch Safari even if you’re not connected to the Internet; there’s a static
web page with basic instructions that automatically opens when you launch
Note: You can only run one application at a time in Recovery Mode, so if you’re
running Disk Utility, say, you can’t also launch Safari. Being aware of this limitation can save you some frustration and endless restarts.
In addition to Recovery Mode’s obvious choices, you can also run Firmware Password Utility, Network Utility, and Terminal by visiting the Utilities drop-down menu
at the top of the screen. With all of these options, most users will find the choices
presented in the OS X Utilities window sufficient to fix their Mac woes.
Here’s how to boot your Mac in Recovery Mode (the process should be familiar if
you’ve booted Macs from alternative disks before): hold down the Option key
while starting your Mac. You’ll be presented with a screen that shows all the viable
startup partitions available. Choose Recovery HD and you’ll be well on your way
to diagnosing (and hopefully fixing) whatever problem is currently plaguing
This section emphasized tools that come with Lion and Mountain Lion because, well,
if you’ve installed either version of OS X, you have access to these tools. But you should
be aware that these tools aren’t the only ones available when things go wrong.
There are several disk-repair programs available (many of which are more powerful
than Disk Utility) from third parties, such as DiskWarrior and TechTool Pro.
Reset your PRAM
This maneuver gets its own section only because it’s one of the oldest troubleshooting
techniques in Mac history.
PRAM (parameter random access memory) is where your Mac stores many of its
hardware settings. Resetting the PRAM almost never resolves a startup issue, but it’s
something Apple support usually asks you to do when troubleshooting a problem
CHAPTER 1: BEFORE YOU HACK
(and it does, in some rare cases, help). To reset the PRAM, turn on your Mac,
immediately press and hold Option-Command-P-R, and continue to hold those keys
until your Mac restarts and your hear the startup chime a total of three times. After
you do this, you may have to reconfigure some of the system settings (like date, time,
and possibly keyboard/mouse settings if you’ve customized them).