A Practical Guide to UNIX® for Mac OS® X Users explains how to work with the UNIX operating system that is the foundation of Mac OS X. This book looks “under the hood,” past the traditional graphical user interface (GUI) that most people think of as a Macintosh, and explains how to use the powerful command line interface (CLI) that connects you directly to UNIX.
Command line interface (CLI). In the beginning UNIX had a command line (textual) interface. There was no mouse to point or icons to drag and drop. Some programs, such as emacs, implemented rudimentary windows using the very minimal graphics available in the ASCII character set. In addition, reverse video helped separate areas of the screen. UNIX was born and raised in this environment.
Naturally all of the original UNIX tools were invoked from the command line. The real power of UNIX, and of Mac OS X, lies in this environment, which explains why many UNIX professionals work exclusively from the command line.
Using clear descriptions and lots of examples, this book shows you how to get the most out of your UNIX-based Mac OS X system using the command line interface. The first few chapters quickly bring readers with little computer experience up to speed. The rest of the book is appropriate for more experienced computer users.
Audience. This book is designed for a wide range of readers. It does not require programming experience, but assumes a basic familiarity with the Macintosh GUI. It is appropriate for the following readers:
- Beginning Macintosh users who want to know what UNIX is, why everyone keeps saying that it is important, and how to take advantage of it
- Experienced Macintosh users who want to know how to take advantage of the power of UNIX that underlies Mac OS X
- Students taking a class in which they use Mac OS X
- Power users who want to explore the power of Mac OS X from the command line
- Professionals who use Mac OS X at work
- UNIX users who want to adapt their UNIX skills to the Mac OS X environment
- Computer science students who are studying the Mac OS X operating system
- Programmers who need to understand the Mac OS X programming environment
- Technical executives who want to get a grounding in Mac OS X
Benefits. A Practical Guide to UNIX® for Mac OS® X Users gives you an in-depth understanding of how to use the UNIX operating system that is the foundation for Mac OS X.
A large amount of free software has always been available for Macintosh systems. In addition, the Macintosh shareware community is very active. By introducing the UNIX aspects of Mac OS X, this book throws open to Macintosh users the vast store of free and low-cost software available for UNIX, Linux, and other UNIX-like systems.
Regardless of your background, this book offers the practical knowledge you need to get on with your work: You will come away from this book understanding how to use the UNIX operating system that underlies OS X, and this text will remain a valuable reference for years to come.
Features of This Book
This book is organized for ease of use in different situations. For example, you can read it from cover to cover to learn about the UNIX aspects of Mac OS X from the ground up. Alternatively, once you are comfortable using OS X, you can use this book as a reference: Look up a topic of interest in the table of contents or index and read about it. Or, refer to one of the utilities covered in Part VI, “Command Reference.” You can also think of this book as a catalog of Mac OS X topics: Flip through the pages until a topic catches your eye. If you are familiar with UNIX or a UNIX-like operating system such as Linux, refer to Appendix C, “Mac OS X for UNIX Users,” which lists some of the differences between Mac OS X and traditional UNIX systems. The book also includes many pointers to Web sites where you can get additional information: Consider the Web an extension of this book.
A Practical Guide to UNIX® for Mac OS® X Users offers these features:
- Optional sections allow you to read the book at different levels, returning to more difficult material when you are ready to tackle it.
- Caution boxes highlight procedures that can easily go wrong, giving you guidance before you run into trouble.
- Tip boxes highlight situations in which you can save time by doing something differently or when it may be useful or just interesting to have additional information.
- Security boxes point out ways that you can make a system more secure.
- The supporting Web site at www.sobell.com includes corrections to the book, downloadable examples from the book, pointers to useful Web sites, and answers to even-numbered exercises.
- Important command line utilities that were developed by Apple specifically for Mac OS X are covered in detail, including GetFileInfo, SetFile, nidump, otool, launchctl, diskutil, and plutil.
- Descriptions of Mac OS X extended attributes including file forks, file attributes, attribute flags, and access control lists (ACLs).
- The relationships between GUI tools and their CLI counterparts are discussed in depth.
- Information that will help you set up servers includes sections on property lists, the launchd superserver, and DHCP.
- A section on NetInfo discusses the NetInfo database and ways to work with it.
- Concepts are illustrated by practical examples found throughout the book.
- Many useful URLs (Internet addresses) identify Web sites where you can obtain software and information.
- Chapter summaries review the important points covered in each chapter.
- Review exercises are included at the end of each chapter allow readers to hone their skills. Answers to even-numbered exercises are available at www.sobell.com.
- Important GNU tools, including gcc, gdb, GNU Configure and Build System, make, gzip, and many others, are described in detail.
- Pointers throughout the book provide help in obtaining online documentation from many sources, including the local system and the Internet.
This section describes the information that each chapter covers and explains how that information can help you take advantage of the power of Mac OS X. You may want to review the table of contents for more detail.
Chapter 1: Welcome to Mac OS X
Presents background information on Mac OS X. This chapter covers the history of Mac OS X, explains the connection between OS X and open-source software including GNU and BSD software, and discusses some of OS X’s important features that distinguish it from other operating systems including other versions of UNIX.
Part I: The Mac OS X Operating System
Tip: Experienced users may want to skim Part I
If you have used a UNIX-like system before, you may want to skim or skip some or all of the chapters in Part I. All readers should take a look at “Conventions Used in This Book” (page 18), which explains the typographic conventions that this book uses, and “Getting the Facts: Where to Find Documentation” (page 27), which points you toward both local and remote sources of Mac OS X documentation.
Part I introduces UNIX on a Mac OS X system and gets you started using it from the command line.
Chapter 2: Getting Started
Explains the typographic conventions that this book uses to make explanations clearer and easier to read. This chapter provides basic information and explains how to log in, display a shell prompt, give OS X commands using the shell, and find system documentation.
Chapter 3: The Mac OS X Utilities
Explains the command line interface (CLI) and briefly introduces more than 30 command line utilities. Working through this chapter gives you a feel for UNIX and introduces some of the tools you will use day in and day out. Chapter 3 also introduces pipes, which allow you to combine utilities on the command line. The utilities covered in this chapter include
- grep, which searches through files for strings of characters;
- ditto, which copies files and directories (folders);
- tar, which creates archive files that can hold many other files;
- bzip2 and gzip, which compress files so that they take up less space on disk and allow you to transfer them over a network more quickly; and
- diff, which displays the differences between two text files.
Chapter 4: The Mac OS X Filesystem
Discusses the OS X hierarchical filesystem from a UNIX perspective, covering files, filenames, pathnames, working with directories (folders), access permissions, and hard and sym...