Unix For Mac Os X

Home > Store

Jan 02, 2003 If you are.serious. about learning Unix for Mac OS X, get a copy of 'Mac OS X: Unleashed' by John and William Ray. At +1,000 pages, the book is a doorstopper, but it covers almost everything a Unix power user aspirant would want to know: how to navigate through Terminal, set up an Apache webserver with PHP and MySQL, etc. For more help with UNIX, try this guide from the University of Edinburgh UNIX Frequently Asked Questions (FAQs) These seven articles contain the answers to some Frequently Asked Questions often seen in comp.unix.questions and comp.unix.shell. Adapted for Mac OS X by Shane Burns from a tutorial by [email protected]


Register your product to gain access to bonus material or receive a coupon.

  • By Mark G. Sobell, Peter Seebach
  • Published Dec 21, 2005 by Pearson.

Unix Vs Mac Os X


  • Sorry, this book is no longer in print.

eBook (Watermarked)

  • Your Price: $31.99
  • List Price: $39.99
  • This PDF will be accessible from your Account page after purchase and requires the free Adobe® Reader® software to read it.

    The eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.


  • Copyright 2006
  • Dimensions: 7-3/8' x 9-1/4'
  • Pages: 1056
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-186333-9
  • ISBN-13: 978-0-13-186333-0
  • eBook (Watermarked)
  • ISBN-10: 0-321-63053-X
  • ISBN-13: 978-0-321-63053-7

The Most Useful UNIX Guide for Mac OS X Users Ever, with Hundreds of High-Quality Examples!

Beneath Mac OS® X's stunning graphical user interface (GUI) is the most powerful operating system ever created: UNIX®. With unmatched clarity and insight, this book explains UNIX for the Mac OS X user—giving you total control over your system, so you can get more done, faster. Building on Mark Sobell's highly praised A Practical Guide to the UNIX System, it delivers comprehensive guidance on the UNIX command line tools every user, administrator, and developer needs to master–together with the world's best day-to-day UNIX reference.

This book is packed with hundreds of high-quality examples. From networking and system utilities to shells and programming, this is UNIX from the ground up—both the 'whys' and the 'hows'—for every Mac user. You'll understand the relationships between GUI tools and their command line counterparts. Need instant answers? Don't bother with confusing online 'manual pages': rely on this book's example-rich, quick-access, 236-page command reference!

Don't settle for just any UNIX guidebook. Get one focused on your specific needs as a Mac user!

A Practical Guide to UNIX® for Mac OS® X Users is the most useful, comprehensive UNIX tutorial and reference for Mac OS X and is the only book that delivers

  • Better, more realistic examples covering tasks you'll actually need to perform
  • Deeper insight, based on the authors' immense knowledge of every UNIX and OS X nook and cranny
  • Practical guidance for experienced UNIX users moving to Mac OS X
  • Exclusive discussions of Mac-only utilities, including plutil, ditto, nidump, otool, launchctl, diskutil, GetFileInfo, and SetFile
  • Techniques for implementing secure communications with ssh and scp—plus dozens of tips for making your OS X system more secure
  • Expert guidance on basic and advanced shell programming with bash and tcsh
  • Tips and tricks for using the shell interactively from the command line
  • Thorough guides to vi and emacs designed to help you get productive fast, and maximize your editing efficiency
  • In-depth coverage of the Mac OS X filesystem and access permissions, including extended attributes and Access Control Lists (ACLs)
  • A comprehensive UNIX glossary
  • Dozens of exercises to help you practice and gain confidence
  • And much more, including a superior introduction to UNIX programming tools such as awk, sed, otool, make, gcc, gdb, and CVS


Author's Site

Visit the author's web site: www.sobell.com

Sample Content

Online Sample Chapter

Table of Contents

Preface xxvii

Chapter 1: Welcome to Linux 1

The GNU-Linux Connection 2

The Heritage of Linux: UNIX 5

What Is So Good About Linux? 6

Overview of Linux 10

Additional Features of Linux 15

Chapter Summary 16

Exercises 17

Part I: The Linux Operating System 19

Chapter 2: Getting Started 21

Conventions Used in This Book 22

Logging In 24

Working with the Shell 25

Curbing Your Power: Superuser Access 28

Getting the Facts: Where to Find Documentation 29

More About Logging In 35

Chapter Summary 38

Exercises 39

Advanced Exercises 39

Chapter 3: Command Line Utilities 41

Special Characters 42

Basic Utilities 43

Working with Files 45

(Pipe): Communicates Between Processes 52

Four More Utilities 53

Compressing and Archiving Files 56

Locating Commands 61

Obtaining User and System Information 63

Communicating with Other Users 67

Email 69

Chapter Summary 69

Exercises 72

Advanced Exercises 73

Chapter 4: The Linux Filesystem 75

The Hierarchical Filesystem 76

Directory and Ordinary Files 77

Working with Directories 88

Access Permissions 91

Links 96

Chapter Summary 102

Exercises 103

Advanced Exercises 105

Chapter 5: The Shell 107

The Command Line 108

Standard Input and Standard Output 113

Running a Program in the Background 125

Filename Generation/Pathname Expansion 127

Builtins 132

Chapter Summary 133

Exercises 134

Advanced Exercises 136

Part II: The Editors 137

Chapter 6: The vim Editor 139

History 140

Tutorial: Creating and Editing a File with vim 141

The compatible Parameter 148

Introduction to vim Features 148

Command Mode: Moving the Cursor 154

Input Mode 158

Command Mode: Deleting and Changing Text 160

Searching and Substituting 164

Miscellaneous Commands 170

Yank, Put, and Delete Commands 171

Reading and Writing Files 174

Setting Parameters 175

Advanced Editing Techniques 180

Units of Measure 184

Chapter Summary 188

Exercises 193

Advanced Exercises 194

Chapter 7: The emacs Editor 195

History 196

Tutorial: Getting Started with emacs 198

Basic Editing Commands 204

Online Help 209

Advanced Editing 212

Language-Sensitive Editing 225

Customizing emacs 235

More Information 240

Chapter Summary 241

Exercises 248

Advanced Exercises 250

Part III: The Shells 253

Chapter 8: The Bourne Again Shell 255

Background 256

Shell Basics 257

Parameters and Variables 277

Processes 292

History 295

Aliases 312

Functions 315

Controlling bash Features and Options 318

Unix For Mac Os X

Processing the Command Line 322

Chapter Summary 332

Exercises 334

Advanced Exercises 336

Chapter 9: The TC Shell 339

Shell Scripts 340

Entering and Leaving the TC Shell 341

Features Common to the Bourne Again and TC Shells 343

Redirecting Standard Error 349

Working with the Command Line 350

Variables 355

Control Structures 368

Builtins 377

Chapter Summary 381

Exercises 382

Advanced Exercises 384

Part IV: Programming Tools 385

Chapter 10: Programming Tools 387

Programming in C 388

Using Shared Libraries 396

make: Keeps a Set of Programs Current 399

Debugging C Programs 407

Threads 417

System Calls 417

Source Code Management 420

Chapter Summary 430

Exercises 431

Advanced Exercises 432

Chapter 11: Programming the Bourne Again Shell 435

Control Structures 436

File Descriptors 470

Parameters and Variables 474

Builtin Commands 487

Expressions 501

Shell Programs 510

Chapter Summary 520

Exercises 522

Advanced Exercises 524

Chapter 12: The gawk Pattern Processing Language 527

Syntax 528

Arguments 528

Options 529

Notes 529

Microsoft for mac os xUnix

Language Basics 530

Examples 537

Advanced gawk Programming 554

Error Messages 559

Chapter Summary 560

Exercises 561

Advanced Exercises 561

Chapter 13: The sed Editor 563

Syntax 564

Arguments 564

Options 564

Editor Basics 565

Examples 568

Chapter Summary 578

Exercises 579

Part V: Command Reference 581

Standard Multiplicative Suffixes 586

Common Options 587

The sample Utility 587

sample: Very brief description of what the utility does 588

aspell: Checks a file for spelling errors 589

at: Executes commands at a specified time 593

bzip2: Compresses or decompresses files 596

cal: Displays a calendar 598

cat: Joins and displays files 599

cd: Changes to another working directory 601

chgrp: Changes the group associated with a file 603

chmod: Changes the access mode (permissions) of a file 604

chown: Changes the owner of a file and/or the group the file is associated with 608

cmp: Compares two files 610

comm: Compares sorted files 612

configure: Configures source code automatically 614

cp: Copies files 616

cpio: Creates an archive or restores files from an archive 619

crontab: Maintains crontab files 624

cut: Selects characters or fields from input lines 627

date: Displays or sets the system time and date 630

dd: Converts and copies a file 633

df: Displays disk space usage 636

diff: Displays the differences between two files 638

du: Displays information on disk usage by file 644

echo: Displays a message 647

expr: Evaluates an expression 649

file: Displays the classification of a file 653

Learning unix for mac os x

find: Finds files based on criteria 655

finger: Displays information about users 661

fmt: Formats text very simply 664

fsck: Checks and repairs a filesystem 666

ftp: Transfers files over a network 671

gcc: Compiles C and C++ programs 678

grep: Searches for a pattern in files 683

gzip: Compresses or decompresses files 688

head: Displays the beginning of a file 691

kill: Terminates a process by PID 693

killall: Terminates a process by name 695

less: Displays text files, one screen at a time 697

ln: Makes a link to a file 702

lpr: Sends files to printers 705

ls: Displays information about one or more files 708

make: Keeps a set of programs current 715

man: Displays documentation for commands 721

mkdir: Creates a directory 724

mkfs: Creates a filesystem on a device 725

Mtools: Uses DOS-style commands on files and directories 728

mv: Renames or moves a file 732

nice: Changes the priority of a command 734

nohup: Runs a command that keeps running after you log out 736

od: Dumps the contents of a file 737

paste: Joins corresponding lines from files 742

pr: Paginates files for printing 744

ps: Displays process status 746

rcp: Copies one or more files to or from a remote system 750

rlogin: Logs in on a remote system 752

rm: Removes a file (deletes a link) 753

rmdir: Removes a directory 755

rsh: Executes commands on a remote system 756

scp: Securely copies one or more files to or from a remote system 758

sleep: Creates a process that sleeps for a specified interval 760

sort: Sorts and/or merges files 762

split: Divides a file in into sections 771

ssh: Securely executes commands on a remote system 773

strings: Displays strings of printable characters 777

stty: Displays or sets terminal parameters 778

tail: Displays the last part (tail) of a file 783

tar: Stores or retrieves files to/from an archive file 786

tee: Copies standard input to standard output and one or more files 791

telnet: Connects to a remote system over a network 792

test: Evaluates an expression 794

top: Dynamically displays process status 798

touch: Changes a file's access and/or modification time 801

tr: Replaces specified characters 804

tty: Displays the terminal pathname 807

tune2fs: Changes parameters on an ext2 or ext3 filesystem 808

umask: Establishes the file-creation permissions mask 810

uniq: Displays unique lines 812

w: Displays information about system users 814

wc: Displays the number of lines, words, and bytes 816

which: Shows where in PATH a command is located 817

who: Displays information about logged-in users 819

xargs: Converts standard input into command lines 821

Part VI: Appendixes 825

Appendix A: Regular Expressions 827

Characters 828

Delimiters 828

Simple Strings 828

Special Characters 828

Rules 831

Bracketing Expressions 832

The Replacement String 833

Extended Regular Expressions 834

Appendix Summary 835

Appendix B: Help 837

Solving a Problem 838

Finding Linux-Related Information 839

Specifying a Terminal 844

Appendix C: Keeping the System Up-to-Date 847

yum: Updates and Installs Packages 848

Apt: An Alternative to yum 850

BitTorrent 855

Glossary 859

Index 913


Untitled Document

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 symbolic links. This chapter also discusses extended attributes including file forks, attribute flags, type codes, creator codes, and Access Control Lists (ACLs). Understanding the filesystem allows you to organize your data so that you can find information quickly. It also enables you to share some of your files with other users while keeping other files private.

Chapter 5: The Shell

Explains how to use shell features to make your work faster and easier. All of the features covered in this chapter work with both the Bourne Again Shell (bash) and the TC Shell (tcsh). This chapter discusses

  • Using command line options to modify the way a command works;
  • How a minor change in a command line can redirect input to a command to come from a file instead of from the keyboard;
  • How to redirect output from a command to go to a file instead of to the screen;
  • Using pipes to send the output of one utility directly to another utility so that you can solve problems right on the command line;
  • Running programs in the background so that you can work on one task while UNIX is working on a different one; and
  • Using the shell to generate filenames to save you time spent on typing and help you when you do not recall the exact name of a file.

Part II: The Editors

Part II covers two classic, powerful UNIX command line text editors. Mac OS X includes the vimtext editor, an “improved” version of the widely used vi editor, as well as the popular GNU emacs editor. Text editors enable you to create and modify text files that can hold programs, shell scripts, memos, and input to text formatting programs.

Chapter 6: The vim Editor

Starts with a tutorial on vim and then explains how to use many of the advanced features of vim, including special characters in search strings, the General-Purpose and Named buffers, parameters, markers, and execution of commands from vim. The chapter concludes with a summary ofvimcommands.

Chapter 7: The emacs Editor

Opens with a tutorial and then explains many of the features of the emacs editor as well as how to use the META, ALT, and ESCAPE keys. The chapter also covers key bindings, buffers, and incremental and complete searching for both character strings and regular expressions. In addition, it details the relationship between Point, the cursor, Mark, and Region. It also explains how to take advantage of the extensive online help facilities available from emacs. Other topics covered include cutting and pasting, using multiple windows and frames, and working with emacs modes—specifically C mode, which aids programmers in writing and debugging C code. Chapter 7 concludes with a summary ofemacscommands.

Part III: The Shells

Part III goes into more detail about bashand introduces the TC Shell (tcsh).

Chapter 8: The Bourne Again Shell

Picks up where Chapter 5 leaves off, covering more advanced aspects of working with a shell. For examples it uses the Bourne Again Shell—bash, the shell used almost exclusively for system shell scripts. Chapter 8 describes how to

  • Use shell startup (preference) files, shell options, and shell features to customize your shell;
  • Use job control to stop jobs and move jobs from the foreground to the background, and vice versa;
  • Modify and reexecute commands using the shell history list;
  • Create aliases to customize commands;
  • Work with user-created and keyword variables in shell scripts;
  • Set up functions, which are similar to shell scripts but can execute more quickly;
  • Write and execute simple shell scripts; and
  • Redirect error messages so that they go to a file instead of the screen.

Chapter 9: The TC Shell

Describes tcsh and covers features that are common to and differ between bash and tcsh. This chapter explains how to

  • Run tcsh and change your default shell to tcsh;
  • Redirect error messages so that they go to files instead of to the screen;
  • Use control structures to alter the flow of control within shell scripts;
  • Work with tcsharray and numeric variables; and
  • Use shell builtin commands.

Part IV: More About Mac OS X

Chapter 10: Networking

Discusses networks, network security, and the Internet. This chapter

  • Covers types of networks, subnets, protocols, addresses, hostnames, and various network utilities;
  • Discusses distributed computing including the client/server model; and
  • Describes briefly some of the servers you can use on a network.

Chapter 11: System Maintenance

Discusses core system concepts including Superuser and the use of sudo as well as system operation. This chapter

  • Provides general information about how to set up a server, including information on property list and other configuration files;
  • Describes how the launchd superserver works;
  • Discusses the NetInfo database and delves into how it differs from the classic UNIX system databases;
  • Describes briefly many important standard directories and files;
  • Explains how to set up a chroot jail; and
  • Describes how DHCP works.

Part V: Programming Tools

Part V covers programming under Mac OS X. It discusses the C programming environment, the use of bash as a programming language, and ways to write programs using awk and sed.

Chapter 12: Programming Tools

Introduces Mac OS X’s exceptional programming environment. This chapter focuses on the traditional UNIX command line development environment because this environment is the one you will likely have to work in with free software developed for UNIX systems. This chapter

  • Discusses the Carbon, Cocoa, and UNIX APIs;
  • Explains how to invoke the GNU gcc compiler;
  • Describes how to use make to keep a set of programs up-to-date;
  • Explains how to debug a C program using gdb;
  • Describes how to work with shared libraries;
  • Explains how to set up and use CVS to manage and track program modules in a software development project; and
  • Discusses system calls and explains how you can use them to initiate kernel operations.

Chapter 13: Programming the Bourne Again Shell

Once you have mastered the basics of OS X, you can use your knowledge to build more complex and specialized programs, by using the shell as a programming language. Chapter 13 shows you how to use bash to write advanced shell scripts. It discusses

  • Control structures such as if...then...else and case;
  • Variables, including locality of variables;
  • Arithmetic and logical (Boolean) expressions; and
  • Some of the most useful shell builtin commands, including exec, trap, and getopts.

Chapter 13 poses two complete shell programming problems and then shows you how to solve them step by step. The first problem uses recursion to create a hierarchy of directories. The second problem develops a quiz program and shows you how to set up a shell script that interacts with a user and how the script processes data. (The examples in Part VI also demonstrate many features of the utilities you can use in shell scripts.)

Chapter 14: The awk Pattern Processing Language

Explains how to write programs using the powerful awk language that filter data and write reports. The advanced programming section describes the powerful getline statement, which gives you better control over bringing data into awk, and the system statement, which allows you to run external commands from within an awk program.

Chapter 15: The sed Editor

Describes sed, the noninteractive stream editor that finds many applications as a filter within shell scripts. This chapter discusses how to use sed’s buffers to write simple yet powerful programs and includes many examples.

Part VI: Command Reference

Mac OS X includes hundreds of utilities. Chapters 14 and 15 as well as Part VI provide extensive examples of the use of more than 90 of the most important utilities with which you can solve problems without resorting to programming in C. If you are already familiar with UNIX, this part of the book will be a valuable, easy-to-use reference. If you are not an experienced user, it will serve as a useful supplement while you are mastering the earlier sections of the book.

Although the descriptions of the utilities in Chapters 14 and 15 and Part VI are presented in a format similar to that used by the Mac OS X manual (man) pages, they are much easier to read and understand. These utilities were chosen because you will work with them day in and day out (for example, ls and cp), because they are powerful tools that are especially useful in shell scripts (sort, paste, and test), because they help you work with your Mac OS X system (ps, kill, sysctl, and GetFileInfo), or because they enable you to communicate with other systems (ssh, scp, and ftp). Part VI also covers several utilities that were developed by Apple for OS X—they are not found on other UNIX systems (nidump, otool, launchctl, and plutil).

Each utility description includes complete explanations of its most useful options. The “Discussion” and “Notes” sections present tips and tricks for using the utility to full advantage. The “Examples” sections demonstrate how to use these utilities in real life, alone and together with other utilities to generate reports, summarize data, and extract information. Take a look at the “Examples” sections for awk (more than 20 pages, starting on page 609), ftp (page 738), and sort (page 837) to see how extensive these sections are.

Part VII: Appendixes

Part VII includes the appendixes and the glossary.

Appendix A: Regular Expressions

Explains how to use regular expressions to take advantage of the hidden power of UNIX. Many utilities, including grep, sed, vim, and awk, accept regular expressions in place of simple strings of characters. A single regular expression can match many simple strings.

Appendix B: Help

Details the steps typically used to solve the problems you may encounter with a Mac OS X/UNIX system. This appendix also includes many links to Web sites that offer documentation, useful UNIX information, mailing lists, and software.

Appendix C: Mac OS X for UNIX Users

This appendix is a brief guide to Mac OS X features and quirks that may be unfamiliar to users who have been using other UNIX or UNIX-like systems.


Defines more than 500 terms that pertain to the use of Mac OS X/UNIX.

The Index helps you quickly find the information you want.


Mark Sobell’s home page (www.sobell.com) contains downloadable listings of the longer programs from this book as well as pointers to many interesting and useful UNIX-related sites on the World Wide Web, a list of corrections to the book, answers to even-numbered exercises, and a solicitation for corrections, comments, and suggestions.

Thanks from Mark G. Sobell

First and foremost I want to thank my editor at Prentice Hall, Mark L. Taub, who encouraged me and kept me on track. His comments and direction were invaluable. Thank you, Mark T.

A big “Thank You” to the folks who read through the drafts of the book and made comments that caused me to refocus parts of the book where things were not clear or were left out altogether: Thank you David Chisnall, computer scientist extraordinaire; Sean Fagan, Apple Computer; Paul M. Lambert, Apple Computer; Nicolas Roard; Stephen Worotynec, Engineering Services, Alias Systems; Gretchen Phillips, Independent Consultant, GP Enterprises; and Peggy Fenner.

Thanks to Molly Sharp of ContentWorks, the production manager who made sure the book came together as it was supposed to; Jill Hobbs, the copy editor who kept the various parts of the English language in their proper relative places; and Andrea Fox, the most amazing proofreader I have ever worked with. Thanks also to the folks at Prentice Hall who helped bring this book to life: Kim Silvestro, Publicist; Stephane Nakib, Marketing Manager; Julie Nahil, Full-Service Production Manager; Noreen Regina, Editorial Assistant; and everyone else who worked behind the scenes to make this book happen.

I am also indebted to Denis Howe, the editor of The Free On-Line Dictionary of Computing (FOLDOC). Dennis has graciously permitted me to use entries from his compilation. Be sure to visit the dictionary (www.foldoc.org).

Dr. Brian Kernighan and Rob Pike graciously allowed me to reprint the bundle script from their book, The UNIX Programming Environment (Prentice Hall, 1984).

Parts of A Practical Guide to UNIX® for Mac OS® X Users have grown from my UNIX and Linux books, and I want to thank the people who helped with those books.

Thank you to Lars Kellogg-Stedman, Harvard University; Jim A. Lola, Principal Systems Consultant, Privateer Systems, LLC; Eric S. Raymond, cofounder, Open Source Initiative; Scott Mann; Randall Lechlitner, Independent Computer Consultant; Jason Wertz, Computer Science Instructor, Montgomery County Community College; Justin Howell, Solano Community College; Ed Sawicki, The Accelerated Learning Center; David Mercer, Contechst; Jeffrey Bianchine, Advocate, Author, Journalist; John Kennedy; Chris Karr; Jim Dennis, Starshine Technical Services; Carsten Pfeiffer, Software Engineer and KDE Developer; Aaron Weber, Ximian; Matthew Miller, Boston University; Cristof Falk, Software Developer at CritterDesign; Scott Mann, IBM, Systems Management and Integration Professional; Steve Elgersma, Computer Science Department, Princeton University; Scott Dier, University of Minnesota; and Robert Haskins, Computer Net Works.

Thanks also to Dustin Puryear, Puryear Information Technology; Gabor Liptak, Independent Consultant; Bart Schaefer, Chief Technical Officer, iPost; Michael J. Jordan, Web Developer, Linux Online Inc.; Steven Gibson, owner of SuperAnt.com; John Viega, founder and Chief Scientist, Secure Software, Inc.; K. Rachael Treu, Internet Security Analyst, Global Crossing; Kara Pritchard, K & S Pritchard Enterprises, Inc.; Glen Wiley, Capitol One Finances; Karel Baloun, Senior Software Engineer, Looksmart, Ltd.; Matthew Whitworth; Dameon D. Welch-Abernathy, Nokia Systems; Josh Simon, Consultant; Stan Isaacs; and Dr. Eric H. Herrin II, Vice President, Herrin Software Development, Inc. And thanks to Doug Hughes, long-time system designer and administrator, who gave me a big hand with the sections on system administration, networks, the Internet, and programming.

More thanks go to consultants Lorraine Callahan and Steve Wampler; Ronald Hiller, Graburn Technology, Inc.; Charles A. Plater, Wayne State University; Bob Palowoda; Tom Bialaski, Sun Microsystems; Roger Hartmuller, TIS Labs at Network Associates; Kaowen Liu; Andy Spitzer; Rik Schneider; Jesse St. Laurent; Steve Bellenot; Ray W. Hiltbrand; Jennifer Witham; Gert-Jan Hagenaars; and Casper Dik.

A Practical Guide to UNIX® for Mac OS® X Users is based in part on two of my early UNIX books: UNIX System V: A Practical Guide and A Practical Guide to the UNIX System. Many people helped me with those books, and thanks here go to Pat Parseghian, Dr. Kathleen Hemenway, and Brian LaRose; Byron A. Jeff, Clark Atlanta University; Charles Stross; Jeff Gitlin, Lucent Technologies; Kurt Hockenbury; Maury Bach, Intel Israel Ltd.; Peter H. Salus; Rahul Dave, University of Pennsylvania; Sean Walton, Intelligent Algorithmic Solutions; Tim Segall, Computer Sciences Corporation; Behrouz Forouzan, DeAnza College; Mike Keenan, Virginia Polytechnic Institute and State University; Mike Johnson, Oregon State University; Jandelyn Plane, University of Maryland; Arnold Robbins and Sathis Menon, Georgia Institute of Technology; Cliff Shaffer, Virginia Polytechnic Institute and State University; and Steven Stepanek, California State University, Northridge, for reviewing the book.

I continue to be grateful to the many people who helped with the early editions of my UNIX books. Special thanks are due to Roger Sippl, Laura King, and Roy Harrington for introducing me to the UNIX system. My mother, Dr. Helen Sobell, provided invaluable comments on the original manuscript at several junctures. Also, thanks go to Isaac Rabinovitch, Professor Raphael Finkel, Professor Randolph Bentson, Bob Greenberg, Professor Udo Pooch, Judy Ross, Dr. Robert Veroff, Dr. Mike Denny, Joe DiMartino, Dr. John Mashey, Diane Schulz, Robert Jung, Charles Whitaker, Don Cragun, Brian Dougherty, Dr. Robert Fish, Guy Harris, Ping Liao, Gary Lindgren, Dr. Jarrett Rosenberg, Dr. Peter Smith, Bill Weber, Mike Bianchi, Scooter Morris, Clarke Echols, Oliver Grillmeyer, Dr. David Korn, Dr. Scott Weikart, and Dr. Richard Curtis.

We take responsibility for any errors and omissions in this book. If you find one or just have a comment, let us know ([email protected]) and we will fix it in the next printing. Mark Sobell’s home page (www.sobell.com) contains a list of errors and credits those who found them. It also offers copies of the longer scripts from the book and pointers to many interesting Mac OS X sites.


Download the Index file related to this title.



Errata for this book is available at: http://www.sobell.com/OSX1/errata.html

Submit Errata

More Information

Other Things You Might Like

  • Book $55.99
  • eBook (Watermarked) $55.99
  • Web Edition $55.99

Home > Store


Register your product to gain access to bonus material or receive a coupon.

  • By Matisse Enzer
  • Published Dec 3, 2002 by Peachpit Press. Part of the Visual QuickPro Guide series.

Premium Website

  • Sorry, this book is no longer in print.



Unix For Mac Os X
  • Proven Visual QuickPro/QuickStart visual learning format—Combines an open, welcoming design, hundreds of screen captures, expert tips, and concise step-by-step instructions.
    • Relies on a format designed to make learning as easy as possible.

  • Comprehensive coverage of Unix fundamentals—Covers navigating the Unix file system, managing permissions and file ownership, and basic system administration.
    • Covers everything students need to quickly become productive and effective with the Unix features and tools Mac OS X provides.

  • Introduction to running Mac OS X as a file, print, or Web server—Includes detailed coverage of Unix tools for providing print and file services, including an introduction to configuring and running the Apache Web server under Mac OS X.
    • Shows students how to use a Mac OS X system to support a workgroup or host a Web site.

  • Introduction to writing and running Unix scripts—Presents basic scripting techniques students can use to automate Mac OS X, application, and server tasks.
    • Helps students accomplish more in less time, and become more effective system and Web administrators.

  • Resources and tools for becoming a more effective user or administrator—Shows how to get help on Unix features, troubleshoot problems, locate free open source software, and install additional software from source code.
    • Gives students all the resources and skills they need to go even further with Unix.

  • Expert tutorial and handy quick reference—Designed not only to teach Unix for the Mac OS X exceptionally well, but also to serve as an outstanding task-based reference.
    • Will remain valuable to students long after they've mastered the fundamentals of Unix.


  • Copyright 2003
  • Edition: 1st
  • Premium Website
  • ISBN-10: 0-201-79535-3
  • ISBN-13: 978-0-201-79535-6

With Mac OS X, Apple has completely rebuilt the Macintosh operating system from the ground up--and yes, it's Unix that's running this new Mac OS. Mac users can now use the terminal command line to write a Perl script, automate batch commands, run an Apache server, use sendmail, and grep to their heart's delight. And alternately, many experienced Unix programmers are thrilled to be able to write shell scripts on the Mac platform. Unix for Mac OS X: Visual QuickPro Guide shows readers how to configure their Unix environment, navigate permissions, directories and files, run handy Unix utilities, configure and run the Apache Web server, and much more. In addition, readers will learn how to protect their files with Unix's security tools, and how to fix their Macs when things go wrong.


Related Article

Author's Site

Click below for Web resources related to this file:
Author's Web Site

Companion Site

Welcome to the Companion Site for Unix for Mac OS X: Visual QuickPro Guide

Table of Contents and Introduction (136K PDF) Chapter 1 (176K PDF) Chapter 2 (228K PDF) Chapter 15 (1.1MB PDF) Appendix A

(92K PDF)

Appendix B (56K PDF) Code Samples (16K Download) 

Sample Content

Online Sample Chapter

Table of Contents


Who Is This Book For? Whats in This Book? How to Use This Book. Requirements.

1. What is Unix, and Why Is It Good?

The Advantages of a Unix-based Mac OS. But First, a Little History. How Mac OS Xs Unix Differs from Mac OS 9. What You Can Do with Mac OS X and Unix. How You Will Be Working with Unix.

2. Using the Command Line.

Getting to the Command Line. Understanding the Shell Prompt. Using a Command. Using Common Commands. About Commands, Processes, and Jobs. About Spaces in the Command Line. Wildcards. About Standard Input and Output. Creating Pipelines of Commands. Running a Command in the Background. Opening Files from the Command Line. Creating a Simple Unix Shell Script.

3. Getting Help and Using the Unix Manual.

Using the Unix Manual. Printing Man Pages. Using Commands Built-in Help. Getting Help from Other People.

4. Useful Unix Utilities.

Mac OS X—Specific Utilities. File Compression and Archiving. File and Text Processing. Searching for Text. Searching for Files. Viewing and Editing Files. Sending Email. Network Analysis. Using the Internet.

5. Using Files and Directories.

Seeing the Whole File System. Seeing Where You Are in the File System. Understanding and Using Unix Filenames. Moving Around in the File System. Seeing the Contents of Directories. Viewing the Contents of Text Files. Creating Files and Directories. Copying Files and Directories. Renaming or Moving Files. Deleting Files and Directories. Getting Information about Files and Directories. About Links (the Unix Version of Aliases).

6. Editing and Printing Files.

Editing Files with vi. About vis Two Modes. Navigating Using vi. Saving a File in vi. Quitting vi. Changing and Deleting Text. Emacs—an Editor Without Modes. Printing Files.

7. Configuring Your Unix Environment.

Finding Configuration Files. Configuring Your Shell. Environment Variables. Shell Aliases. Shell Settings. Configuring vi.

8. Working with Permissions and Ownership.

About Users and Groups. The Root User—Permission to Do Anything. Understanding Permissions and Ownership. Setting and Changing Permissions. Changing Ownership. Default Permissions for File Creation. Recognizing Permission Problems.

9. Creating and Using Scripts.

Creating a Shell Script. Using Variables. Using Arguments. Using Commands within Commands. Doing Arithmetic and Using Expressions. Using Control Structures. Getting User Input. Creating and Using Functions.

10. Connecting Over the Internet.

About Hostnames. Logging in to Another Unix Machine. Copying Files Between Unix Machines. More Advanced Interactions.

11. Introduction to Systems Administration.

About root. Becoming Another User. Backups. Managing User Accounts and Groups. Monitoring System Usage. Running Regularly Scheduled Commands. System Log Files. The Boot Sequence. Setting the Hostname. Creating a New StartupItem. Webmin—A GUI Tool for System Administration. Troubleshooting Tips.

12. Security.

Physical Security. Choosing Good Passwords. Protecting Yourself from Internet Attacks. Searching for Files that Make You root. Keeping Up-to-Date. Monitoring Files for Changes. Security Checklist.

13. Installing Software from Source Code.

Installing from Source Code—the Basics. Using Fink to Install Software. Manually Installing from Source Code. Installing Perl Modules.

14. Installing and Configuring Servers.

Setting Your Machines Hostname. Controlling the AppleShare Server. Activating the SSH Server. Configuring Sendmail—Internet Email Server. Activating the FTP Server. Apache: A Web Server. Even More Servers.

Appendix A. For More Information.

About Darwin. About Open-Source and Free Software. General Help Resources. Languages and Programming. Mac OS X in General. People. Protocols and Standards. Security. System Administration. Unix in General. Unix/Darwin Software. Miscellaneous.

Appendix B. Glossary.


Updates & Corrections

Unix for Mac OS X: Visual QuickPro Guide
ISBN 0-201-79535-3
Page 515 , The Bash Reference Manual
The URL has changed:


Download the current list of Errata

Submit Errata

Unix For Mac Os X Users With Kevin Skoglund

More Information

Other Things You Might Like

  • Book $31.99
  • eBook (Watermarked) $25.59
  • eBook (Watermarked) $38.39