While Unix is best known as a server operating systemmost of the servers on the Internet run Unixit's also been the desktop operating system for engineers , software developers, and system administrators. But Mac OS X is placing a Unix-based system on millions of desktops. With Unix under the hood of Mac OS X, Macintosh users are now able to take advantage of software developments beyond the boundaries of Apple Computer, while still enjoying the elegance and ease of use for which the Mac OS is famous.
Basing Mac OS X on the Darwin operating system gave it three important features that, for all its advantages, the Mac OS had not previously had: stability, flexibility, and openness.
Even the most devoted Macintosh user will admit that system crashes have been an unfortunate but predictable part of everyday life. Unix systems, however, are extremely difficult to crash. Thanks to protected memory the memory each application uses that is unavailable to any other applicationwith Mac OS X your Macintosh will continue running even when one or more applications crash. You can simply restart the crashed application without having to restart your Mac.
If your system doesn't have protected memory, a badly behaving application can disturb the memory space of another application, or even of the operating system itselfoften with nasty results. Macintosh operating systems before Mac OS X didn't include protected memorywhich explains all those system crashes!
A feature called preemptive multitasking allows the operating system to limit the amount of computational resources devoted to each application by prioritizing between tasks . Before Mac OS X, the Mac OS employed cooperative multitaskingin which each application is supposed to behave and play well with the other applications on a machine. You can guess what happens when cooperatively multitasked applications don't cooperate.
Unix was designed to allow different programs to be connected in an almost infinite variety of ways. Because thousands of utilities are available for Unix (and because they work together so well), Unix users can customize their work environments relatively easily, building their own tools when the need arises. Mac OS X itself comes with around 500 utilities, most of which can be easily combined with other programs (see Chapter 4, "Useful Unix Utilities," for a roundup of the ones you're most likely to use). Because of this (and its portability), Unix is the ideal environment for developing new software.
Like other open-source versions of Unix, such as Linux, Darwin is openthat is, the inner workings are open to examination and change. You can download, study, and alter its programming source code at will. (In fact, versions of Darwin other than Apple's already exist.) Say you want to create a server that enables you to synchronize an iPod with any computer over the Internet, or one that sends faxes on demand from a catalog of fileswhatever software you create is likely to use an existing piece of Unix software as its starting point.
What's in a Name ?
Strictly speaking, Unix is a trademarked term that's been variously owned by AT&T, Novell, and now the Open Group (www.opengroup.org). Only Unix versions with the correct legal pedigree can use that name. In reality, though, most people casually refer to all the various "flavors" as Unix.
By allowing people to examine and change their operating systems, open-source software is central to the ongoing evolution and spread of Unix, resulting in a software-development environment that will continue to increase in stability, flexibility, and power.
Unix's ability to connect different programs together provides almost infinite flexibility. Combine this with Unix's built-in support for TCP/IP (the networking protocol that defines the Internet) and other networking tools, and you have an operating systemMac OS Xthat's ready to take you into a future where you can build your applications, and every computer has the ability to be a server.
Other Versions of Unix
Over the years , many versions of Unix have been developedsome by large corporations (for example, Sun Microsystems' Solaris and Hewlett-Packard's HP/UX), and some by small companies and individuals working for their own pleasure . The most famous of the latter is the open-source GNU/Linux operating system, which combines the work of hundreds of programmers from around the world and has been adopted by thousands of companies. (For example, IBM announced in January 2002 a mainframe computer designed specifically for Linux, and in 2005 Brazil's National Institute of Information Technology is planning to make computers running Linux available to citizens at subsidized prices of $500 or less.)
A good list of dozens of versions of Unix is available at www.ugu.com/sui/ugu/show?ugu.flavors.
Whatever capability you want to add to an application, you can probably do it in Darwin. As a Mac enthusiast, you may have had limited exposure to any kind of programming, but you'll be able to expand your horizons by accessing the Unix underlying Mac OS X. Even if you're brand-new to programming, delving into Unix is the best way to start.
Thus, you should read this book because you want a deeper understanding of your computer, and to get your fingers and hands and mind inside of it. Using Unix is about moving from being a consumer of software and systems to being a creator of software and systems. This means pushing the envelope of how you interact with the operating system, delving into areas where most users don't go, in order to develop capabilities that most users don't have. Mac OS X makes this possible because Unix is an operating system for developing and building, for getting into the nitty-gritty.
Since much Unix software is created by volunteers, you're benefiting from the hard work of thousands of users. But using Unix means you will always tweak, modify, and configure to get the software to do what you want. By bringing an industrial-strength server to your desktop, Apple has taken desktop computing to another levelin much the same way that Macintosh-plus-PostScript laser printers brought high-quality print publishing and graphics tools to the desktop. None of this is automatic, though, and using Unix places a greater burden on you. If you're coming to Unix expecting the shrink-wrapped experience of the Mac OS or Windows, you're bound to be disappointed.
You will work with Unix primarily from the command line in the Terminal application (more about that in the next chapter). You will put together lots of odd-sounding commands, creating tiny and not-so-tiny scripts and programs to give the machine capabilities it never had before. Not only will you be customizing your machine and creating software, but also you will be customizing your world, and indirectly the world that the rest of us live in.
Most people won't really notice that Mac OS X is Unix based. In fact, most people will use their Mac OS X Macintoshes just as they always havewriting in their word processors, creating images in graphics software, and editing sound and video.
Some of the Unix tools in Mac OS X were available in some form for Mac OS 9, but the Unix versions are included with Mac OS X (for example, a Web server and an e-mail server). With Mac OS X, you are more likely to work with these applications for a couple of reasons. Mac OS X is so stable that you won't be afraid of messing up your computer. More important, if you use a "pure" Unix tool, like the Apache Web server, then the skills you learn, and the system you build, will be transferable to almost any other Unix environment with little effort.
Unix is more hands-on than the graphical user interfaces you're accustomed to. However, if you're ready to experience new heights of computing creativity, you'll find that you have a more personalized and robust system on your hands by the time you finish this book.
From Multics to Unix
Unix wasn't actually named until about a year into its developmentat which point the wordplay on the preceding Multics project was intentional ( uni , meaning one , as opposed to multi , meaning many ). The tradition of puns and word games in Unix software continues to this day, as you'll see in later chapters when we introduce programs such as less , which is an improvement on an earlier program called more . More became less, you see.