Washington Apple Pi

A Community of Apple iPad, iPhone and Mac Users

Unix on Mac OS X: A Review

© 2002 Lawrence I. Charters

Washington Apple Pi Journal, reprint information

Many long time users of Apple computers do not think much of Mac OS X. They haven't tried it, but know it is "different," and even though Apple has said for years it wants people to "think different," many users want to think the same old way they've always thought -- particularly when it comes to their computers.

On the other hand, huge numbers of people (hundreds of thousands? millions?) have become Apple users specifically because of Mac OS X. Many of the old Mac faithful look at Mac OS X and think, "Yech! Unix!" while the new wave thinks, "Yes! Unix!"

As it turns out, both the old faithful and the new wave find Mac OS X "different." It really is a Mac operating system first, and Unix second, as the newcomers discover. And it really is running on top of Unix, as old timers discover when they try to pretend they are still running Apple DOS or Mac System 7.

There are many resources for learning Mac OS X as a Mac operating system, but relatively few which explicitly addressed it as a Unix operating system. Peachpit Press, the best-known publisher of Mac books, only recently started looking at Mac OS X as a Unix operating system. On the other hand, O'Reilly and Associates, the legendary publishers of Unix books, has added several Mac specific titles to its large library of Unix resources. One unconfirmed report claims that O'Reilly's Mac titles have eclipsed sales of all their other titles, by a large margin.

Unix for Mac Users

One new title, Learning Unix for Mac OS X, by Dave Taylor and Jerry Peek, is clearly aimed at helping Mac users become Unix users. From the preface to the index at the back of the book, the authors assume you want to know how to do "Unix things" with Mac OS X. It starts from the premise that you are an experienced Mac user, and know how to use a mouse, move files around, configure peripherals, and all the other usual essentials, so none of these tasks are covered. Instead, it talks about the Unix file system and directory structure (and how these differ from the traditional Mac way of handling files and directories), discusses how to edit files in Unix, how to customize the Terminal application, and similar topics, large and small.

Once you've mastered these basics, it ventures on to printing from Unix (and even suggests that you might want to skip this section), discusses remote login, and delves into various ways of transferring files via the command-line interface. (But it doesn't discuss curl, one of the more interesting Unix commands in Mac OS X.) Next, it discusses Lynx, a text-based Web browser that isn't included with Mac OS X but is easy to add, and various methods of approaching electronic mail in Unix, as well as interactive chat and Usenet news. An appendix walks the user through configuring sendmail -- which is definitely not a trivial task.

The preface mentions that the book is similar to another O'Reilly title, Learning the Unix Operating System, but with an obvious Mac focus. Assuming you really do understand how a Mac works, and want to venture on into Unix, the book does an outstanding job of covering the subject. You won't learn anything about programming or Unix scripting, and basic Unix system administration and security are not addressed. And there are some odd choices and errors. At one point, for example, the simple, easy to use pico text editor is barely mentioned in favor of several pages devoted to vi, which is anything but simple and easy to use. Yet an alphabetical table of vi commands seems to have been arbitrarily cut off at the letter "o" because there was no more room at the bottom of the page. Still, the errors are minor and the quibbles are few; the book is excellent.

Mac OS X for Geeks

Another O'Reilly title takes an opposite approach: Mac OS X for Unix Geeks, by Brian Jepson and Ernest Rothman, is aimed at Unix power users who want to use a Mac as a Unix workstation. It starts off explaining that Terminal is not quite the same as xterm, the popular X Window terminal found on Unix workstations, and explains how to configure it, along with setting up startup tasks and cron tasks. One clever tip is this one-line command:

sudo periodic daily weekly monthly

When accompanied by an appropriate password, this command will run -- all at once -- the daily, weekly and monthly Unix maintenance tasks. This is quite handy, especially if you shut down your Mac and don't leave it running in the hours past midnight, when these scripts are normally executed.

Directory services are covered extensively, including both the use of the Mac OS X graphical tools as well as the Unix-style command-line tools. If you need help in making Mac OS X completely non-functional, a few hours misusing this section of the book should destroy almost any system.

Part II of the book is devoted to building applications, and discusses compilers, system libraries, headers, frameworks, packages, prebinding, and lots of other topics that allow you to reach out and grab Unix (or in some cases, Linux) source code and recompile it for use on your Mac. If you've installed the Mac OS X Developer Tools and have heard of Fink, and would like to know how to use the "make" command, this section of the book is invaluable.

Part III will probably have little appeal to most Mac users, even power users: it discusses how to build the Darwin kernel at the heart of Mac OS X, and talks about installing the X Window system using XDarwin. Since Mac OS X users don't need a graphical user interface -- they have Aqua -- and they don't need to compile the Darwin kernel -- Mac OS X already has it -- this material will be mostly of academic interest. On the other hand, if you need your Mac to talk to a remote Unix box via X Window, an entire chapter is devoted to the topic.

Rounding out the book are two appendices. The first gives an exhaustive, briefly annotated but enlightening listing of the Mac OS X file system. The second covers "missing man pages" for command line tools included in Mac OS X. (O'Reilly could add a companion series to their "Missing Manual" series: "Missing man pages.")

As the title suggests, this book is definitely "geeky," yet well done. Recommended, especially if you have a prior Unix background, or if you are interested in compiling programs for Mac OS X.

Visual Unix

An older book that doesn't even mention Mac OS X is Visual Quickstart Guide: Unix, by Debora and Eric Ray. Previously reviewed by Washington Apple Pi, it is part of Peachpit's famed Visual Quickstart series, so virtually all Mac users should be quite comfortable with how the material is presented. Aside from the extensive coverage of many Unix commands, there are two chapters devoted to running and writing Unix scripts, complete with the usual highly visual examples for which this series is famous. These two chapters alone make the book worth seeking out.

Unix for the Literate

On his personal Web site, Jon Lasser calls Think Unix "an intro-to-Unix book for smart people." It certainly is one of the most literate and, in unexpected ways, humorous computer books yet written. Lasser is a Baltimore area "local," having graduated from Goucher College and served for several years as a Unix system administrator at the University of Maryland, Baltimore County. None of this is particularly relevant except that many people confuse him with John Lasseter, one of the founders of Pixar Animation Studios, located 2,500 miles away in California. Lasseter probably is a Unix guru, but if you hear someone say he wrote Think Unix in between films -- it isn't true. Lasseter works for Steve Jobs; Lasser is a self-employed Unix security consultant and a couple decades younger.

Biography aside, Think Unix is a delight. Rather than teach commands, Lasser teaches concepts and themes, starting with simple things like man pages, files, processes and the like, and moving on to shells and shell scripts, and ending with a large section on X Window. The last section is probably the least useful for Mac users, but the rest of the book is a delight, especially if you have a dry sense of humor. For example, in a discussion of files (Unix thinks almost everything is a file), he talks about an example file called tao.txt that consists of a list of names of Chinese philosophers. A microscopic, unobtrusive note at the bottom of the page states that, "The file which can be named isn't the true file." (Well, I found it funny...)

Almost all of the concepts are presented with small snippets of code for the reader to try out, and there are practice problems to prod you into applying what you've learned. If you feel like cheating, one of the appendices has answers to all the problems.

The other appendix is "Glossary and References," and is anything but boring. What other Unix glossary, for example, has an entry for "beer?" The references include recommended books, and URLs to relevant Web sites, including this one: a text version of Neil Stephenson's history of Unix: In the Beginning Was the Command Line:

http://cryptonomicon.com/beginning.html

Even though it never mentions Mac OS X, Think Unix is highly recommended.

Unix for the Desperate

Finally, in the "authoritative but not necessarily approachable" realm is Arnold Robbins' Unix in a Nutshell, 3rd ed. Subtitled "A Desktop Quick Reference for System V Release 4 and Solaris 7," it quite obviously is not a Mac OS X reference. Instead, it is nearly 600 pages of Unix commands, with almost no narrative text and with almost no examples. In fact, if you aren't at least somewhat familiar with Unix, the book is remarkably opaque; you certainly can't use it to learn Unix.

On the other hand, despite the fact that Mac OS X is built on BSD Unix and not Solaris or AT&T System 7, Unix in a Nutshell is one of the best, if not the best, reference guide to Unix commands. Once you understand the organization of the book, and assuming you know enough about Unix to be dangerous, it presents virtually every Unix command imaginable in one place, with the options spelled out in short, terse descriptions. If you are in desperate need of a Unix reference, and you know enough to know what you are looking for (a kind of circular desperation), the book is invaluable.

Previous editions of Unix in a Nutshell were difficult to use if you weren't already familiar with exactly what you needed. For example, if you wanted to know how to copy a file, there was no index entry for "copy;" you had to know (in advance) that you wanted the cp command or, possibly, the ftp command. This edition has added some English language phrases to the index, making it easier for mere mortals to find what they need. Recommended, though not until after you've developed some mastery of Unix.

One thing you won't find in any of these books: should Unix be written with just the first letter capitalized, or should it be written as UNIX, with every letter capitalized? Most of these books use the former, though AT&T (which invented Unix) seems to prefer the latter. This question, like many other Unix questions (System V vs. BSD, Linux vs. Unix, vi vs. Emacs), probably doesn't have a nice, neat answer. In other words, it is well worth arguing about.

Dave Taylor and Jerry Peck, Learning Unix for Mac OS X. O'Reily, 2002. xiv, 139 pp. $19.95. ISBN 0-596-00342-0

http://www.oreilly.com/catalog/lunixmacosx/

Brian Jepson and Ernest E. Rothman, Mac OS X for Unix Geeks. O'Reilly, 2003. xvi, 198 pp. $24.95. ISBN 0-596-00356-0

http://www.oreilly.com/catalog/mosxgeeks/

Deborah S. Ray and Eric J. Ray, Visual Quickstart Guide: Unix. Peachpit, 1998. xii, 354 pp. $17.99. ISBN 0-201-35395-4

http://www.peachpit.com/

Jon Lasser, Think Unix. Que, 2000. viii, 290 pp. $29.99. ISBN 0-7897-2376-X

http://www.quepublishing.com/

Arnold Robbins, Unix in a Nutshell: A Desktop Quick Reference for System V Release 4 and Solaris 7, 3rd ed. O'Reilly, 1999. xvi, 599 pp. $29.95. ISBN 1-56592-427-4

http://www.oreilly.com/catalog/unixnut3/