Mac Hacks (6 page)

Read Mac Hacks Online

Authors: Chris Seibold

Tags: #COMPUTERS / Operating Systems / Macintosh

BOOK: Mac Hacks
12.94Mb size Format: txt, pdf, ePub
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.

Hack 6
. 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 replacement.

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.

Figure 1-19. 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
).

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.)

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
Figure 1-21
).

Figure 1-21. 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.

Hack 7
. 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., dial
1-800-275-2273.

Misbehaving Applications

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.

Figure 1-22. 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 Option-Command-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 dialog box.

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 JavaScript code.) When you identify
a suspect, single-click the renegade process’s 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.

Startup Problems

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.

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://datacent.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 #1]
) 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.

Figure 1-23. 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.

Startup troubleshooting

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
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.”

Safe Boot

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 Safari.)

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 your
Mac.

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 (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).

Other books

Fat by Keene, James
Stuff to Die For by Don Bruns
A Chorus of Innocents by P F Chisholm
Helga's Web by Jon Cleary
And Then You Die by Iris Johansen
FATAL eMPULSE by Mark Young