BUY THIS BOOK

Safari Books Online

What is this?

Looking to Reprint this content?


Mac OS X Hacks
Mac OS X Hacks 100 Industrial-Strength Tips & Tricks By Rael Dornfest, Kevin Hemenway
March 2003
Pages: 430

Cover | Table of Contents | Colophon


Table of Contents

Chapter 1: Files
The Mac OS X filesystem is a blend of powerful, ancient Unix underpinnings and the candy-coated shell known as the Macintosh Finder. To make this a reality, Mac OS X pulled off quite a switcheroo! It yanked the filesystem of Mac OS 9 and earlier out from underneath the Finder's feet, replacing it with the utterly foreign world of the Unix filesystem and all that goes with it.
While all but invisible to the casual user, there are some cracks in the façade, visible upon closer inspection. Some are useful, others a little irritating, and still others simply fascinating and quite hack-worthy.
The hacks in this section poke and prod at the seams, revealing some useful techniques for backing up your system, tweaking files and folders, bending aliases to your will, understanding how it all fits together — even dumpster divingin the Trash a little.
Before Mac OS X was released, there wasn't really a concept of a user or account in the Macintosh environment. This hack introduces you to what it means to have an account and what this business of a Home directory is all about. We'll also show you how to rename an account — a nonobvious task indeed.
When Mac OS X first appeared, a lot of people were aghast at the concept of user accounts, especially when they were the only ones using their computer. "Why go through all the hassle when only I exist?" they asked. The complaints only intensified as users were asked to enter an administrator password [Hack #50] for access to certain files, sometimes even denied access to settings and files on their very own computers — the gall of it!
The reasoning is two-fold: to protect you from yourself and to support Mac OS X's multiuser environment.
The concept of protecting you from yourself may at first blush appear intrusive, but we've all had an instance where we've deleted an innocent file from our OS 9 System Folder, only to discover our idiocy when our system didn't reboot, our printer didn't print, or our modem didn't sizzle. In this regard, OS X has your back; crucial files necessary for everyday operation are protected from overzealous removal.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Hacks #1-12
The Mac OS X filesystem is a blend of powerful, ancient Unix underpinnings and the candy-coated shell known as the Macintosh Finder. To make this a reality, Mac OS X pulled off quite a switcheroo! It yanked the filesystem of Mac OS 9 and earlier out from underneath the Finder's feet, replacing it with the utterly foreign world of the Unix filesystem and all that goes with it.
While all but invisible to the casual user, there are some cracks in the façade, visible upon closer inspection. Some are useful, others a little irritating, and still others simply fascinating and quite hack-worthy.
The hacks in this section poke and prod at the seams, revealing some useful techniques for backing up your system, tweaking files and folders, bending aliases to your will, understanding how it all fits together — even dumpster divingin the Trash a little.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Understanding and Hacking Your User Account
Before Mac OS X was released, there wasn't really a concept of a user or account in the Macintosh environment. This hack introduces you to what it means to have an account and what this business of a Home directory is all about. We'll also show you how to rename an account — a nonobvious task indeed.
When Mac OS X first appeared, a lot of people were aghast at the concept of user accounts, especially when they were the only ones using their computer. "Why go through all the hassle when only I exist?" they asked. The complaints only intensified as users were asked to enter an administrator password [Hack #50] for access to certain files, sometimes even denied access to settings and files on their very own computers — the gall of it!
The reasoning is two-fold: to protect you from yourself and to support Mac OS X's multiuser environment.
The concept of protecting you from yourself may at first blush appear intrusive, but we've all had an instance where we've deleted an innocent file from our OS 9 System Folder, only to discover our idiocy when our system didn't reboot, our printer didn't print, or our modem didn't sizzle. In this regard, OS X has your back; crucial files necessary for everyday operation are protected from overzealous removal.
The multiuser environment of OS X is based on technology that's been around for a while in the Unix world: a system of checks and balances that stop your kid sister from gleefully deleting that Photoshop file you've been working on all weekend. Whether you're the only user isn't a concern; protection from the inside (yourself, your kid sister) and protection from the outside (malicious crackers, viruses, and trojans) becomes paramount.
While a determined user can delete any file on their OS X machine with enough effort (the easiest way being to boot into OS 9), Apple has wisely made it difficult to do so through Mac OS X.
When creating an account (System Preferences Accounts New User . . . ) — either the initial account upon installing Mac OS X, or an additional account — you'll be prompted for both your Name (e.g., John Jacob Jingleheimer Schmidt) and something called a Short Name (see Figure 1-1).
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Taking the Bite Out of Backup
With a confusing array of backup solutions for Mac OS X, we pick out a couple of our favorites: Apple's Backup and the open source, Perl-based psync.
Backup is the bane of anybody's computer existence. You know it's an integral part of data hygiene — not unlike flossing, in fact. But it's late, you have a presentation in the morning, and you're too busy creating data to bother finding a CD or some extra hard drive space to shove a backup set onto. Not that you'd know what and how to back up in the first place.
Many of the available software applications don't work as advertised, are complicated when they shouldn't be, don't restore as one would hope during your time of need, and are often expensive to boot. Online backup always sounds like a good idea; and it is, for reasonably sized data sets, meaning not mine and probably yours.
Backup proves such a pain that you never really think about it until it's too late — again, much like flossing.
So what's a data hog to do?
Backup (http://www.mac.com/1/iTour/tour_backup.html), .Mac's free personal backup software, has the simplicity you've been craving in a backup application.
It sports an intuitive iApp-style interface and an intelligent QuickPicks feature to help you identify important files and locate them on your hard drive for you rather than the hunt-and-peck of lesser backup programs. You can back up to CD or DVD, even spanning multiple CDs or DVDs should your important data be just that much. If you're a .Mac member ($99.95 per year), you have 100 megabytes of iDisk space (upgradable up to 1 gigabyte for a fee) that can be used for remote backup. That 100 megabytes isn't much and will be gobbled up pretty quickly if used as your primary backup space, but it's useful for backing up your address book, keychain, Internet Explorer settings and favorites, Quicken financial data, and a few other vital files while you're on the road.
Disappointingly, Backup doesn't allow you to back up to an internal or external hard drive, meaning that my 20-gigabyte external FireWire simply can't be used by this utility. Otto Moerbeek has a nice hack for running Apple's Backup without a .Mac account (
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Backing Up on the Go
Combining .Mac services with 802.11b connectivity provides some vital protection for current projects while on the road.
Generally speaking, I'm pretty good about backing up my PowerBook data. But sometimes a few days go by between sessions. I used to think that such a span was acceptable, but these days, when every hour of work is as precious as gold, I'm rethinking my old habits.
I don't want to replace my existing system. I like it. What I really want to do is add the capability to temporarily back up work files to protect me between archiving sessions. As I was mulling over this situation, I noticed a nice convergence of technologies that presented me with a solution.
After I upgraded my .Mac membership, I took a look at the new tools available. At this point, the one that interests me the most is the Backup (http://www.mac.com/) application. Clearly, I didn't see this as a total solution to my archiving needs, especially with a measly 100MB iDisk, but I thought that Backup had some potential as a temporary container for my work in progress.
The appealing aspect of this new application is that I can designate particular folders on my hard drive to be copied to my iDisk whenever I have a network connection. At the end of each work session, for example, I simply click the Backup Now button, and the latest version of my designated files is copied to my iDisk (see Figure 1-10). That means instead of risking 24 hours or more between archiving sessions, I'm constantly saving my most important documents many times a day.
Figure 1-10: Backup
The log files for Backup are very accessible and help me keep track of the success of my sessions. I recommend that you use the Show Toolbar view of Backup, enabling you to access your log files directly from the main interface. Also, to keep this system as efficient as possible, don't designate too many items to back up — your sessions will run too long and defeat the purpose of having an easy-to-use safety net during the course of your workday.
For the most part, the application's behavior has been steady. Every now and then I get a strange pop-up notice that I need to join .Mac to use Backup. I just click the Quit button, and Backup continues to go about its business uninterrupted.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Dealing with Archives of Many Colors: .img, .sit, .tar, .gz
Back in the innocent days of OS 9, one compression format reigned supreme: Stuffit from Aladdin Systems. With OS X and its BSD Unix foundation, there's a whole slew of compression technologies available, all built into your default installation.
Stuffit Expander, DropStuff, and their Aladdin ilk have long been stalwarts of the Mac OS, included on Apple CDs and preinstalled machines. The same can be said for Unix utilities like gzip, bzip2, and compress, also included with OS X and available through the Terminal. Throw in Apple's disk-image technology, which creates archives that look and act like removable disks, and you've got a veritable cornucopia of compression and archival technologies.
Apple has been providing disk image technology in the shape of its Disk Copy utility for years now. Creating a disk image is a mindless task — simply open Disk Copy, drag a folder over the floating window (see Figure 1-11), decide if you want encryption, and choose where to save the resultant file (see Figure 1-12).
Figure 1-11: Dragging a folder into Disk Copy
Figure 1-12: Setting Image Folder options
Creating image files, however, doesn't offer much compression, and you'll see a lot of dmg.gz extensions on your new downloads. That leads us into gzip and tar. gzip is as much of a Unix standard as Stuffit has been for the Mac. By itself, it's only a compression utility — it doesn't bundle and archive multiple files like Aladdin's DropStuff (also included in OS X). For that ability, it's most often combined with another utility called tar or with the generated disk images from Apple's Disk Copy. If you want to compress a .dmg file you've just created, you'd jump into the Terminal [Hack #48]:
gzip -9 filename.dmg
This command will automatically compress filename.dmg into filename.dmg.gz, at maximum compression. If we don't include the -9, then gzip will finish slightly faster, but at the expense of a slightly larger file size (
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
A Line Break Is a Line Break
A line break is a line break is a line break, except when it's not. Surprisingly, there are three different types of line breaks in the modern computing world, and OS X uses two of the three.
One might think the innocent line break, that docile whitespace that tells us when paragraphs begin and end, would be a relatively simple piece of computer engineering. Unfortunately, there's more to the line break than meets the eye.
There are three different types of line breaks, all originally unique to the major operating systems: Windows/DOS, Macintosh, and Unix. A document using Mac line breaks would look horrid on a Windows system, and a document using Windows line breaks on Unix also wouldn't be interpreted correctly. The cause for this is how the line break is actually created. The Mac, by default, uses a single carriage return (<CR>), represented as \r. Unix, on the other hand, uses a single linefeed (<LF>), \n. Windows goes one step further and uses both, creating a (<CRLF>) combination, \r\n.
To make matters still more interesting, until OS X came along, OS-specific line breaks stayed in their own environment and didn't play nicely with others. Windows understood only its brethren, Unix cackled madly at anything else, and the Mac just grinned knowingly. OS X, however, understands both the original Mac line break and Unix line breaks.
This can cause confusion very easily, especially considering that most Mac applications (i.e., most anything that runs through the GUI of OS X) read and save using Mac-style line breaks, while anything used through the Terminal (like the common text editors [Hack #51]: vi, pico, and Emacs) enforces the Unix variety.
Thankfully, it's pretty easy to solve problems caused by this dual mentality. The first step is identifying that you have an issue. Say you have a text file you saved with SimpleText or a default installation of BBEdit. If you try to open that file in a shell editor like vi, you'll see this instead of what you'd expect:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Fiddling with Type/Creator Codes and File Extensions
Mac OS X uses a combination of type and creator codes and file extensions to determine the application with which a file is associated.
Every file in OS X and earlier versions of the Mac OS usually have both a type and creator attribute that help determine which application should open them. For example, a .html file may have a type and creator that say it should be opened in Microsoft's Internet Explorer, while a .mov file would have different attributes that suggest it should be opened by QuickTime. Files also have other attributes, like stationary, locked or unlocked, and timely information like creation and modification dates.
Unlike Windows, however, a Mac file doesn't need an extension to determine association with an application. A file named webcam could be a JPEG image, a text file to be opened by BBEdit, or even an HTML file associated with Internet Explorer. The type and creator codes rise above petty naming distinctions.
Normally, you'd need special software to set or change these types and creators, making the task more difficult (or expensive) than you'd hope. Longtime users of the Mac OS would often use the venerable ResEdit to perform the dirty deed, perhaps also tweaking other application strings in a fit of mirth and because they're there.
Thankfully, if you've installed Apple's Developer Tools, you can do this easily with the Terminal [Hack #48].
The easiest way to change a file's type and creator codes is to find a file you want to mimic and use its type and creator codes as a guide for your changes. For example, if you had a copy of Apple's home page (http://www.apple.com) saved as an HTML file named Apple Home.html, you'd enter the following into a Terminal [Hack #48] window to find its type and creator:
% /Developer/Tools/GetFileInfo "Apple Home.html"
         
The output would look something like this:
file: "Apple Home.html"
type: "TEXT"
creator: "MSIE"
attributes: avbstclinmed
created: 08/08/2002 19:12:46
modified: 08/08/2002 19:12:46
With this, we know that a file associated with Internet Explorer needs to have a type of TEXT and a creator of MSIE. If you check other files, you'll notice that types and creators are always four letters in length, often creating ungodly combinations of whimsy, like DBSE and FTCH, which have nothing to do with what you might think they do (an Extensis Portfolio database).
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Locking and Unlocking Files
For years, the Macintosh operating system has allowed you to lock a file or folder to protect against accidental deletion or modification. In OS X, you have that same ability, either through the Finder or the shell.
If there's one thing that friends and family know, it's how to find that one file you've been spending an inordinate amount of time on and then delete it in a fit of gleeful innocence. For many years in Mac OS 9 and earlier, the first line of defense for this behavior has been locking a file, making sure that it can't be changed or deleted unless it is specifically unlocked.
This ability remains in Mac OS X and applies even to the root user (locked files can't be deleted without being unlocked first, period). Longtime Mac users are familiar with the following process for locking a file or directory in the Finder:
  1. Select the file or directory you want to lock.
  2. Choose Get Info from the File menu or press -I.
  3. Place a check in the Locked checkbox.
Either of the following two shell commands do the same thing under OS X:
% chflags uchg filename.txt
% /Developer/Tools/SetFile -a L filename.txt
         
The chflags utility is part of a default OS X install and changes the uchg flag of a file, representing the immutable bit (literally, "this file is not subject to change"). chflags can be performed only by a superuser or the file's owner. SetFile is a utility that comes with the Developer Tools and operates on a file's attributes (attributes and flags can be considered equivalent). In this case, you're saying the locked attribute (-a L) of the file should be set.
Via the Finder, you can tell when a file is locked because it'll have a padlock icon superimposed over the lower left of its normal icon, as shown in Figure 1-16.
Figure 1-16: A locked file
In the Terminal [Hack #48], you can type ls -ol (o to show the file flags, and l for long listing). Any file with the uchg flag is locked:
% ls -ol filename.txt
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Stubborn Trash, Stuck Images, and Jammed CDs
Every so often it takes a little know-how to empty the Trash or eject a CD; learn when and how.
There are times, rare as they may be, when OS X goes a little haywire and simply won't spit out a CD or DVD, unmount a disk image, or empty the Trash. Often things have a way of sorting themselves with a little patience, with a Finder restart, by logging out and back in, or (heaven forbid) by rebooting your Mac. Sometimes, however, that stuck CD/DVD or image doesn't budge or the Trash simply refuses to empty.
It does the heart good to do some occasional housekeeping. One such activity is emptying the Trash folder to free up more disk space for your Mac. This is usually as simple as Finder Empty Trash . . . or -Shift-Delete. Every so often, though, a file or folder refuses to leave.
First a little background on the mystical Trash can. Every file you delete is moved into a folder called .Trash in your home directory:
% ls -al
total 48
drwxr-xr-x 20 weimengl staff 680 Dec 14 12:35 .
drwxrwxr-t 8 root wheel 272 Dec 10 09:30 ..
drwx------ 6 weimengl staff 204 Dec 14 12:55 .Trash
...
To dip into the Trash, simply open a Terminal [Hack #48] window, navigate to the .Trash directory, and list files:
% cd .Trash
% ls -al
            
Emptying the Trash is nothing more than deleting all the contents of your .Trash folder.

Section 8.1.1: In use

Despite having been placed into the Trash, a file may still be in use by an application (see Figure 1-17).
Figure 1-17: Trashed file still in use
The remedy is to guess which application is using it and close the file or shut down the application if you're no longer using it. Try emptying the Trash again and, assuming that was the problem, it should empty without incident.
If you aren't able to figure out what application is using the file and have shut down just about anything you can find, launch the Terminal and use the fstat (file status) command to ascertain which is the offending program:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Aliases, Symlinks, and Hard Links
Poking about with aliases, symlinks, and hard links reveals some interesting entanglements in the merging of the Mac GUI and its Unix underpinnings.
Aliases (shortcuts, if you're from the Windows world) are indispensable for those of us who insist upon filing things in more than one place or like to have access to particular groupings of applications, files, and whatnot within easy reach. An alias provides a trail of bread crumbs to the original item aliased, keeping track of it no matter where it might reside. It was common in OS 9 to add aliases for your oft-used applications and folders either right on the desktop or in the Apple menu, or, indeed, both. Now, thanks to the Dock and some Dock alternatives [Hack #51], there's little need to clutter your Apple menu or Desktop with aliases.
That's not to say that OS X doesn't have aliases; it does indeed. Simply select a file, folder, application, or whatnot and select File Make Alias or press -L (in OS 9 it was -M, which now, sadly, minimizes the current window instead).
OS X being a hybrid of the Mac and Unix worlds causes some interesting entanglements when it comes to keeping track of the locations of things and their aliases. Mac OS X does a seamless job of glossing over the details. That doesn't mean, however, it's not worth poking about a bit.
The Unix world's aliases — actually called links — come in two flavors: hard and soft (symbolic). With a hard link, two or more filenames point to the same data on disk; think my house, our house, and the house where I live. A symbolic link (a.k.a. soft link or symlink) is a different file from the original, holding nothing but a link to the original's filename; think address book, signpost, or bank account number. Remove one of two hard links and your data still exists. Remove the last remaining hard link and a symlink doesn't do you a bit of good, holding no real data itself.
The ln command creates and alters links on the command line via the Terminal [Hack #48]. Figure 1-20 shows me creating a file,
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Recent Filenames
Mac OS X has some tricky ways of remembering which files were used recently.
Did you know that OS X applications don't actually remember the names of recent files you've opened? That's not to say that they don't recall what you've been editing; after all, Open Recent does work rather nicely.
What the application remembers is the location of the file on disk. Rename that file. Change its file extension. Move it somewhere else entirely. Just as long as it's still on the same disk (inodes don't transfer from disk to disk), your app should be able to find it the next time you choose Open Recent.
Just how this is implemented varies from application to application. Starting with a file called somefile.txt on my Desktop, I did a little experimenting. Move, rename, and tamper with it as I might, BBEdit continued to list it as Hard Drive:Users:rael:Desktop:somefile.txt. Preview noticed a rename of somefile.tiff to someotherfile.tiff. Microsoft Word, like BBEdit, insisted somefile.doc was still somefile.doc, despite its being renamed someotherfile.doc and moved elsewhere.
Why's this useful? Let's say you've created a marvelous piece of poetry, saved it to the Desktop in a hurry as your plane lands, later renamed it to something more appropriate than Untitled1.doc, and moved it somewhere or other. Sure, Sherlock may be able to find it if you search by content, date changed, or document type. Or you could simply relaunch the app you believe you were using at the time, select it from the list of recent files, and you're off to the races.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Inspecting the Contents of an .app Package
If you were an OS 9 fiddler, tweaker, or deviant, there was one piece of software you simply had to have: ResEdit, Apple's venerable, unsupported, use-at-your-own risk utility. ResEdit is no longer applicable under OS X, but package editing is.
In earlier versions of the Mac OS, files could have data forks and resource forks. The data fork was the gooey inside, and the resource fork was the fluffy outside — whether it be image thumbnails, saved editing data from applications like BBEdit, or application widgets, like window layouts, user interface images, and so forth. With Apple's ResEdit, you could easily access this resource fork and change the fluff — it wasn't easily possible to change the coding of an application, but it was certainly mindless to change interface elements.
In OS X, with its grounding in the BSD operating system, resource forks are rarely used for applications, effectively making ResEdit useless. Instead, we've got packages or, less jargony, files that end in .app. You've got .app files spread all over your OS X system already — you just may not know it. Take, for instance, Apple's popular Mail program. It sits innocently in your Applications folder, acting as if it were a single file. Instead, it's really called Mail.app; the .app is hidden from view (you can confirm its existence by examining the Get Info properties).
The magic of these .app files is that they're really a special kind of folder called a package; they contain a good portion of the same fluff available in an OS 9 application's resource fork. Even better, you don't need an extra utility like ResEdit to start fiddling; simply Control-click on a file you know is an .app and choose Show Package Contents, as shown in Figure 1-21.
Figure 1-21: Revealing package contents via Control-click context menu
Once inside the package Contents folder, you'll see a subfolder called Resources (see Figure 1-22). If you needed yet another hint that this is similar to ResEdit hacking, then this naming choice is it. In the case of Apple's Mail, we can see a decent number of image files, representative of various visual elements you see during normal use of Mail, as well as a few
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Opening Microsoft Word Documents Without Microsoft Word
The text of any Microsoft Word document is readable with the greatest of ease thanks to a tiny, free utility and a little open source know-how.
You open an innocent email from some long-lost relative, and she's sent you a vitally important document. "Open now!" the email shouts, comical in its attempt to disguise the friendly spam it really is. Even worse, the attachment is a Microsoft Word document, and you've yet to pony up the dough for Office under OS X. How do you read it? Run out and get some large Word equivalent like AbiWord or AppleWorks, or download a free, 300K utility?
Crafty, experimental users realize that every file or document ever created can be opened up in a plain-old text editor. Whether you actually get something useful is up for grabs, but more times than not, you can recover a bit of meaning from a Word document by dropping it into your friendly neighborhood text editor, as shown in Figure 1-23. In some cases, you can actually learn information the sending user didn't intend for you to know — like the location on her hard drive where it was originally saved.
Figure 1-23: A Word document in TextEdit
But I digress. Opening Word documents in BBEdit or TextEdit (or even vi, pico, or Emacs for shell [Hack #48] lovers) is a hack at best — one we could certainly do without in our beloved OS X. That's where AntiWordService (http://www.devon-technologies.com/) from DEVONtechnologies comes in. It's a very small and easy-to-install piece of freeware that will give any Cocoa application the ability to open Microsoft Word documents. Download, drop into your ~/Library/Services directory, log out and back in, and drag that dastardly .doc to TextEdit. Bingo! Instant plain text. It's not perfect, as the documentation confesses: only plain text is preserved, no images and no formatting. But in most cases that's more than enough, since you're opening up a Word document; naturally, you should be interested only in the words.
One thing of note about AntiWordService is how it's a perfect marriage of the OS X ease of use and the power of Unix, now part of Apple's OS for the next fifteen years. In actuality, AntiWordService is just an OS X wrapper around an open source shell utility called
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Chapter 2: Startup
As you stare admiringly at that elegant white-on-gray Apple logo and are mesmerized by that spiraling progress spinner, you may notice the quiet ticking, grinding, and plinking emanating from your Mac's innards. Before fading to a brilliant blue and filling your screen with colorful icons and that familiar menu bar, there's an awful lot going on behind the scenes to bring your Mac to life.
And it isn't all that pretty.
This chapter takes a peek beneath the surface at just what's making all that noise. We'll show you how to boot from another device, turn your Mac into a FireWire hard drive, get OS X running on that old Power Mac in your closet, and lock up your Mac good and tight so that only those with the right key can get to your stuff.
A lot goes on behind the scenes whenever you restart your Macintosh; verbose booting provides a unique glimpse of the Unix underpinnings of Mac OS X.
A lot goes on behind the scenes whenever you restart your Macintosh. In pre-OS X days, we couldn't really tap into this knowledge; at most, we knew what control panels and extensions had been started, but that was about it. Nicely, OS X gives us a few ways we can turn on verbose booting, providing more esoteric knowledge for our coffers.
Being able to see exactly what goes on when you start your computer is easier than you may think. Longtime OS 9 users may recall the Shift or spacebar keyboard tricks: hold one down during bootup and you'll disable, or interactively choose, your extensions, respectively. The same principle lies behind verbose booting in OS X: simply hold down the and V keys.
When you do this during startup, your screen should turn black and you'll see tiny text instead of the normal happy Mac or Apple logo. Most of this text may not make much sense to you, but some messages about your hardware will appear as OS X tries to figure out what you've got plugged in or installed.
You may find that the text scrolls by too fast for your inquisitive mind to handle. No worries, though; since OS X is based on Unix, nearly everything gets written down. Once you're logged into the Finder, open a Terminal window and enter the following command:
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Hacks #13-17
As you stare admiringly at that elegant white-on-gray Apple logo and are mesmerized by that spiraling progress spinner, you may notice the quiet ticking, grinding, and plinking emanating from your Mac's innards. Before fading to a brilliant blue and filling your screen with colorful icons and that familiar menu bar, there's an awful lot going on behind the scenes to bring your Mac to life.
And it isn't all that pretty.
This chapter takes a peek beneath the surface at just what's making all that noise. We'll show you how to boot from another device, turn your Mac into a FireWire hard drive, get OS X running on that old Power Mac in your closet, and lock up your Mac good and tight so that only those with the right key can get to your stuff.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Getting a Glimpse of the Boot Process
A lot goes on behind the scenes whenever you restart your Macintosh; verbose booting provides a unique glimpse of the Unix underpinnings of Mac OS X.
A lot goes on behind the scenes whenever you restart your Macintosh. In pre-OS X days, we couldn't really tap into this knowledge; at most, we knew what control panels and extensions had been started, but that was about it. Nicely, OS X gives us a few ways we can turn on verbose booting, providing more esoteric knowledge for our coffers.
Being able to see exactly what goes on when you start your computer is easier than you may think. Longtime OS 9 users may recall the Shift or spacebar keyboard tricks: hold one down during bootup and you'll disable, or interactively choose, your extensions, respectively. The same principle lies behind verbose booting in OS X: simply hold down the and V keys.
When you do this during startup, your screen should turn black and you'll see tiny text instead of the normal happy Mac or Apple logo. Most of this text may not make much sense to you, but some messages about your hardware will appear as OS X tries to figure out what you've got plugged in or installed.
You may find that the text scrolls by too fast for your inquisitive mind to handle. No worries, though; since OS X is based on Unix, nearly everything gets written down. Once you're logged into the Finder, open a Terminal window and enter the following command:
dmesg
This displays the system message buffer and covers everything before the OS X logging daemon boots up (called syslogd, it's common across Unix installations). The output from your dmesg will contain most of the hardware lines I mentioned before, as well as a few other nitpicks here and there; what you see will be unique for your combination of hardware and equipment.
Once the OS X logging daemon comes into play, the rest of your data is saved into /var/log/system.log, the normal place for messages like these. If you open that file up in any text editor (like vi or Emacs), you'll see the output from
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Booting from Another Device
Boot and run your Mac from another device, whether it's an internal hard drive or an external FireWire drive.
I was thrilled to have the chance to try out a seed build or two of Mac OS X 10.2 (Jaguar) before final release. That is, until yet-unnoticed bugs with the Quartz rendering engine turned my screen to mush and compatibility problems with some of my old settings rendered an application all but unusable.
Thank goodness I'd not actually installed the prerelease on my iBook's hard drive, but was running it from an external FireWire hard drive. A quick reboot and I was back to my trusty 10.1.5 partition running on my internal drive.
Macintosh makes it easy to boot from another device. No need to fiddle with a BIOS or horrid boot.ini files. And absolutely no need to unplug one drive to have the Mac recognize and use another.
To boot from another device, make sure it's plugged in, is recognized by Mac OS X, and has a bootable partition containing a usable operating system. Shut down your Mac (Apple menu Shut Down). While holding down the Option key, turn on your Mac. You'll be greeted with the screen shown in Figure 2-1.
Figure 2-1: Booting from another device
I have only one partition listed, despite having an external FireWire drive plugged in; the FireWire drive doesn't have a viable operating system on it at present, so it is excluded from the list of possibilities. Were I to have more than one usable device/operating system, they would be listed alongside Macintosh HD.
Your mouse pointer will probably look like a watch for a time as your Mac scans attached and internal hardware for possible boot devices. You can force a rescan — perhaps after plugging in another device — by clicking the button with the semicircular icon on the left.
When you're ready, choose a device by clicking on it. Macintosh HD, in my case, is already selected. Click the button with the right arrow on the right to boot.
Of course, if you just want to boot from another partition on your local hard drive — you want to pop into Mac OS 9 for a moment, for instance — you should use the Startup Disk preference pane (
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Turning Your Mac into a Hard Drive
Boot your Mac in target mode and treat it like just another FireWire drive.
I got my brand-spanking-new 800MHz iBook the other day. I was short on time — finishing this book, in fact — but couldn't wait to make the switch from my existing Mac to my sleek, snappy bundle of OS X joy. How could I move all of my applications and home directory (/Users/rael)? I could do without the eternity I'd have to wait transferring it over the network. I didn't relish the number of CDs I'd have to burn to bring across all 3 gigabytes. And the idea of picking through the clutter on my external FireWire drive to make room left me ill.
If only I could mount my old machine's hard drive alongside the new one without tools and duct tape. Surely I could just treat my old Mac as a hard drive somehow. I sure could, and did.
It turns out you can mount one Mac's hard drive onto another Mac over FireWire quite easily. You simply tie them together with a FireWire cable and reboot one of them with the T (for target) key held down.
This assumes, of course, that you have a FireWire-capable Mac on both ends.
After just a few seconds, my old machine booted into what's known as target mode, the screen blinking a FireWire logo where usually there'd be a Mac OS X login screen. A click, spinup, and whirr later, my old hard drive showed up right on my new Mac's desktop.
Thanks to Macintosh's tradition of not spreading installed software all over the hard drive, I was able to drag over individual applications from my Applications folder. I dragged my home directory over and logged out and back in again and I was moved in, preferences and Desktop as I'd left them on the other machine. And all that in around 23 minutes, from boot to enjoy.
When you're done, eject the mounted drive by dragging it to the Trash or selecting it and pressing -E. As far as the target machine's concerned, just turn it off or reboot it when you're finished; it'll come back up as if it were all just a dream.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Using Open Firmware Password Protection
Password-protect your Mac, blocking circumvention by booting from another device, booting into single-user mode, and more.
There are times when you want nary a finger but your own fiddling with your computer. No sister, no boss, no mother looking for porn, no husband reading chat logs. With the Open Firmware built into newer models of the Mac (iBooks, G4s, some iMacs, etc.), you have access to a strong, low-level way of password protecting your Mac from meddling interlopers and innocent wanderers.
Before we go any further, you'll have to check whether your computer has the necessary firmware. To do so, open the Apple System Profiler (under /Applications/Utilities/) and look under the System Overview section for the Boot ROM version (which also represents your Open Firmware version), as shown in Figure 2-3. On my dual 450MHz G4 running 10.2.2, you can see Boot ROM info with a value of 4.2.8f1. To be eligible for password protection, you'll need later than 4.1.7 or 4.1.8 (firmware upgrades are available at Apple's web site).
Figure 2-3: Apple System Profiler
Once we've met the version prerequisites, what exactly does this password protection prevent? Longtime users of the Mac OS may recall such pre-OS X hacks as holding down the Shift key or customizing your extensions with the spacebar, as well as the ability to boot from a CD. While extensions don't exist under OS X, Open Firmware blocks all other avenues that do, including booting up with the C, N, or T keys depressed, in single or verbose mode, or zapping the PRAM. It'll also require a password if you try to edit its settings or get into the Startup Manager.
As with most technology, there's more than one way to set the password, depending on your skills. Apple provides a utility that will do all the magic for you in a pretty GUI (see the link in the See Also section of this hack). Simply download the installer, run the single screen configuration, and reboot your machine to solidify your password protection.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
OS X for This Old Mac
Give your legacy Mac hardware a nudge into OS X with the XPostFacto hack.
Wait, don't throw out that old Power Mac or Umax clone; it may just be up for a little Mac OS X sprucing. Some of those old Macs will actually run Mac OS X 10.2 (Jaguar) — with a little help from an unassuming-looking control panel.
I recently gave an old 7500 a G3 upgrade card from Sonnet (http://www.sonnettech.com/), a quad-port FireWire card, and a dual-port USB card (only $37, combined). Mac OS 9 ran rather snappily and the machine served quite nicely as a USB print server. Then I stumbled across a little something called XPostFacto (http://eshop.macsales.com/OSXCenter/XPostFacto/), which is open source and free.
XPostFacto is a little hack that brings Mac OS X, OS X Server, and Darwin to older, unsupported, and forgotten Mac models — those draped in the unfashionable beige of times past.
Before you think of giving XPostFacto a whirl, be sure to consult the compatibility chart at:
http://eshop.macsales.com/OSXCenter/XPostFacto/framework.cfm?page=XPostFacto.html#preparing
Also, make sure your machine has been recently backed up. You're dealing with an unsupported hack here.
You can find XPostFacto site's comprehesive documentation at:
http://eshop.macsales.com/OSXCenter/XPostFacto/framework.cfm?page=XPostFacto.html
The procedure in a nutshell is:
  1. Boot into Mac OS 9.
  2. Insert your standard-issue Mac OS X installation CD.
  3. Run the XPostFacto application (icon shown in Figure 2-4).
  4. Point XPostFacto at the install CD and target volume.
  5. Click the Install button.
  6. Follow the usual installation instructions.
Figure 2-4: The XPostFacto utility
It'll take a while, mind you. Have some coffee, read The New York Times, watch a movie, and have a good meal. When you return, if all's gone according to plan, OS X should be humming away on your old throwaway Mac.
Other World Computing does offer XPostFacto support for a one-time $10 fee. If you're going to be running OS X on a legacy machine in a real production environment — as opposed to just seeing if it can be done — making the investment in some help may just be worthwhile.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Chapter 3: Multimedia and the iApps
Apple has positioned the Mac as a digital hub, the nexus for the otherwise disparate components of your iLife. It has more than backed up this claim with a suite of simply powerful applications: iPhoto, your digital shoebox; iTunes, your personal audio jukebox; iMovie and iDVD, for the budding independent filmmaker; iCal to keep track of where you're supposed to be next; and iSync to keep all your devices in sync.
Add to this Apple's .Mac online service, ever more integrated into your Mac's online life. Back up your Mac's preferences and those important documents you have with you on the road. Check your mail, consult your address book, and share your calendar through any ordinary web browser.
It's all coming together rather nicely. That doesn't mean there isn't room to hack. This chapter provides tips and techniques for getting the most out of the iApps and third-party multimedia applications. Going beyond what the iApps provide out of the box, we'll also glue together audio, video, text, and photos in some unexpectedly useful and fun combinations.
iChat is more than just a great instant messenger client. Here is a collection of tips to get the most out of this fabulous addition to the iApp family.
The moment it became available, just about every Mac geek I knew dropped their AIMs, Adiums, Fires, Jabbers, and Proteuses and made the switch to iChat, Apple's iApp-flavored instant messaging client. What's not to love? It's colorful, friendly, and decidedly Mac. But there's more beneath the candy-coated surface than just another instant messenger (IM) application.
This hack is all about getting the most out of iChat through a few useful tips and delightful surprises discovered between "Up late?," "We're moving that meeting to Friday," and "Dinner's ready!"
Before you do anything else, be sure to put a face to your IM name. There's nothing quite as distancing as a conversation with a generic AIM (AOL Instant Messenger) icon. Whether you choose a cartoon character close to your heart or a recent promo snapshot you were badgered into, simply drag an image into the buddy icon well at the top right of the iChat buddy list window (see Figure 3-1) and it'll appear along with your name or IM handle in your buddies' buddy lists.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Hacks #18-32
Apple has positioned the Mac as a digital hub, the nexus for the otherwise disparate components of your iLife. It has more than backed up this claim with a suite of simply powerful applications: iPhoto, your digital shoebox; iTunes, your personal audio jukebox; iMovie and iDVD, for the budding independent filmmaker; iCal to keep track of where you're supposed to be next; and iSync to keep all your devices in sync.
Add to this Apple's .Mac online service, ever more integrated into your Mac's online life. Back up your Mac's preferences and those important documents you have with you on the road. Check your mail, consult your address book, and share your calendar through any ordinary web browser.
It's all coming together rather nicely. That doesn't mean there isn't room to hack. This chapter provides tips and techniques for getting the most out of the iApps and third-party multimedia applications. Going beyond what the iApps provide out of the box, we'll also glue together audio, video, text, and photos in some unexpectedly useful and fun combinations.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Top iChat Tips
iChat is more than just a great instant messenger client. Here is a collection of tips to get the most out of this fabulous addition to the iApp family.
The moment it became available, just about every Mac geek I knew dropped their AIMs, Adiums, Fires, Jabbers, and Proteuses and made the switch to iChat, Apple's iApp-flavored instant messaging client. What's not to love? It's colorful, friendly, and decidedly Mac. But there's more beneath the candy-coated surface than just another instant messenger (IM) application.
This hack is all about getting the most out of iChat through a few useful tips and delightful surprises discovered between "Up late?," "We're moving that meeting to Friday," and "Dinner's ready!"
Before you do anything else, be sure to put a face to your IM name. There's nothing quite as distancing as a conversation with a generic AIM (AOL Instant Messenger) icon. Whether you choose a cartoon character close to your heart or a recent promo snapshot you were badgered into, simply drag an image into the buddy icon well at the top right of the iChat buddy list window (see Figure 3-1) and it'll appear along with your name or IM handle in your buddies' buddy lists.
Figure 3-1: Dragging a picture into the buddy icon well
As shown in Figure 3-2, iChat's Buddy Icon dialog allows you to scale and position your preferred image until it's just right. Slide the little blue ball left and right to scale the image. Drag the image itself around until it's where you like it. Click Done when you're done.
Figure 3-2: Resizing and positioning a buddy icon
Change your buddy icon any time you wish, depending on mood, interest, or just randomly to confuse and delight your friends.
Rendezvous (http://www.apple.com/macosx/jaguar/rendezvous.html), Apple's branding of a larger standardization effort called Zeroconf (http://www.zeroconf.org/), allows for devices to broadcast their existence and discover others on a local network, peering and making use of each other's available services — all with zero configuration. iChat has Rendezvous baked right in. It'll notice other iChat users coming and going on the local network, keeping track of the transient population in a Rendezvous buddy list (see Figure 3-3).
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
AIM Alternatives
There are various feature-packed alternatives to the default AOL Instant Messenger client for Mac OS X.
When people started discovering AOL's Instant Messenger taking up a large portion of their CPU for seemingly menial (or nonexistent) tasks, the proverbial chad hit the fan; people wanted something better and they wanted it now, regardless of what silly or pointless features they may end up missing. Let's take a brief look at some of the alternatives that have gained popularity:
iChat (http://www.apple.com/ichat/)
Since Apple ships iChat with its OS X 10.2, there's a very good chance that iChat will become the reigning champ of AIM imitators. Created with the blessing of AOL itself, iChat supports chats, file transfers, and buddy icons and uses a GUI that manifests messages into cartoon-style balloons (which don't look as bad as they sound). It has strong support for Mail (a column that tells you if the sender of the email is online) and the Address Book, along with the ability to customize which actions will be performed for a number of common events (buddy logging in, buddy typing, etc.).
Adium (http://www.adiumx.com)
Adium has been gaining a strong following for guerrilla AIM users, mainly due to its immense customization and its low system requirements. It has a clean and refined interface, as well as being minimal for those worried about screen real estate. It's free and is built using Cocoa (and thus gets a number of things for free: spellchecking, antialiasing, etc.).
Fire (http://www.epicware.com/fire.html)
Fire is the granddaddy of instant messengers for OS X; it's been around as long as OS X has and has consistently been improved from version to version. It's open source and it shows, offering langauge localizations contributed by others, hearty amounts of bug fixes, soundsets, icons, and more. While its interface may not be the prettiest, its ability to hook into AIM, Yahoo!, MSN, ICQ, Jabber, and IRC is a clincher for those with multiple service needs.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Printing to PDF or Bitmapped Image
Printing to PDF or bitmapped TIFF image under OS X is built right in, available to almost any application with Print functionality.
OS X's reliance on PDFs for everything from the Dock to Print Preview presents quite a boon when it comes to PDF viewing support and the creation of simple PDFs. While it's something that ordinarily requires specialized software, printing to PDF or bitmapped TIFF image under OS X is built right in, available to almost any application with the ability to print.
From your application, choose Print — almost always File Print or -P. In the Print dialog, select the application-specific settings from the pull-down menu (Copies & Pages should be selected by default) and make any adjustments you wish. These range from simple font selection to Internet Explorer's wide-page handling and control over the inclusion of headers and footers, images, and backgrounds. Some applications make their options available outside of the Print dialog via an Option button. When you're ready, rather than being tempted by the pulsating Print button, click Preview (see Figure 3-12).
Figure 3-12: Internet Explorer's Print dialog
If Print Preview's more visual way of adjusting options is more your game — and is available to you in the application at hand — go right ahead. When you're finished, click Print in the Print Preview dialog followed by Preview in the Print dialog and you're back with the class.
Previews are handled, appropriately enough, by the Preview application, the lightweight PDF viewer that comes with OS X. You'll see a fresh, piping hot PDF of whatever it was you were printing. To save the PDF, select File Save As PDF . . . , rename Preview of whatever.pdf to something nicer, select your preferred save location, and click the Save button. Don't worry about that .pdf file extension [Hack #6]; if you lop it off, OS X will kindly stick it back on for you.
If you prefer to save the preview as a bitmapped TIFF image, select instead File Save As . . . or the key combination Shift-
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Image Conversion in a Pinch
The ability to convert images from one format to another with minimal retouching and manipulation is built right into Mac OS X.
Every so often — but not often enough to warrant shelling out for a full-scale draw or paint program — I find myself needing to convert an image from one format to another. Perhaps I have a photo in TIFF format I'd like to incorporate into my web site as a JPEG or GIF. Or I need to share a screenshot with a Windows user who prefers BMP to PNG.
Thankfully, OS X users have some minimal functionality for image conversion and alteration built right into their OS.
Preview takes me back to the days when a web browser became a launchpad for a plethora of helper apps, specialized viewers for images, movies, or sounds. It's the helper you always wished for for all things image, able to open, save, and convert PDF, JPEG, TIFF, PNG, and others, as well as to export a Photoshop image as a GIF, a Windows BMP to Quicktime, or a fancy new PNG to old faithful MacPaint.
Open an image via File Open, -O, or double-clicking an image file or dragging and dropping it to Preview's Dock or Finder icon. Choose File Export . . . , pick an output format, and save. For a mite more fine-tuning, click the Options . . . button in the Save sheet to set color depth, simple filtering, interlacing, and the like, as shown in Figure 3-13.
Figure 3-13: Exporting to a different image format
Now, don't expect much more than open and save. Preview has some minimal flipping and rotating, but that's about it. Most notably lacking is the ability to crop, a must-have when creating screenshots or a doing a quick hack job on an unduly large image before forwarding it via email.
iPhoto (http://www.apple.com/iphoto/), while best suited to its primary role of digital shoebox, does provide some useful conversion facilities in a pinch. It's far more limited than Preview in the image formats it supports (JPG, TIFF, and PNG) but has a good deal more features up its sleeve: scaling, simple brightness and contrast controls, red-eye reduction, rotation, cropping, one-click enhance, retouching, and converting to black and white.
Additional content appearing in this section has been removed.
Purchase this book now or read it online at Safari to get the whole thing!
Top 10 iPhoto Tips
Yes, at first glance, iPhoto appears deceptively simple. But there's a Unix-compatible database lurking beneath that beautiful Aqua surface.
At first glance, Apple's iPhoto (http://www.apple.com/iphoto) appears deceptively simple. You plug in your digital camera, iPhoto grabs all the pictures, and you play with them on your computer screen.
This process is so easy, in fact, that the next thing you know you have hundreds, if not thousands of images annexing real estate on your hard drive. At some point sobriety settles in, and you realize that you need to back up those iPhoto images. Or you may want to move them to ano