MAC OS X UNIX Toolbox - Christopher Negus - E-Book

MAC OS X UNIX Toolbox E-Book

Christopher Negus

4,9
23,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Explore a ton of powerful Mac OS X UNIX commands This handy, compact guide teaches you to use Mac OS X UNIXsystems as the experts do: from the command line. Try out more than1,000 commands to find and get software, monitor system health andsecurity, and access network resources. Apply the skills you learnfrom this book to troubleshoot networks, lock down security, anduncover almost anything you care to know about your Mac OS Xsystem. Expand your Mac OS X UNIX expertise in these and otherareas: * Using the shell * Finding online software * Working with files * Playing with music and images * Administering file systems * Backing up data * Checking and managing running processes * Accessing network resources * Handling remote system administration * Locking down security

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 287

Bewertungen
4,9 (18 Bewertungen)
17
1
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents
Title Page
Copyright Page
Dedication
About the Authors
Credits
Acknowledgements
Introduction
Who Should Read This Book
What This Book Covers
How This Book Is Structured
What You Need to Use This Book
Conventions
Chapter 1 - Starting with UNIX on Mac OS X
About FreeBSD, NetBSD, and OpenBSD
Finding Mac OS X Resources
Focusing on Mac OS X Commands
Summary
Chapter 2 - New to Mac OS X?
What Is Mac OS X UNIX?
Finding Terminal and Utilities
Directory Structure
Your Home Directory
Spotlight
Getting and Using Fink
Mounting and Unmounting Drives
Learning to Love Launchd
Summary
Chapter 3 - Using the Shell
Terminal Windows and Shell Access
Using the Shell
Acquiring Super User Power
Using Environment Variables
Creating Simple Shell Scripts
Summary
Chapter 4 - Working with Files
Understanding File Types
Setting File and Directory Permissions
Traversing the File System
Copying Files
Searching for Files
Finding Out More About Files
Summary
Chapter 5 - Manipulating Text
Matching Text with Regular Expressions
Editing Text Files
Listing, Sorting, and Changing Text
Summary
Chapter 6 - Advanced Scripting
Shell Scripting on Mac OS X
Using the Script Command
AppleScripting
Working with the Open Command
Summary
Chapter 7 - Administering File Systems
Understanding File System Basics
Creating and Managing File Systems
Mounting and Unmounting File Systems
Checking File Systems
Finding Out About File System Use
Summary
Chapter 8 - Backu ps and Removable Media
Backing Up Data to Compressed Archives
Backing Up over a Network
Summary
Chapter 9 - Checking and Running Processes
Listing Active Processes
Finding and Controlling Processes
Summary
Chapter 10 - Managing the System
Monitoring Resources
Mastering Time
Starting and Stopping Your System
Straight to the Kernel
Summary
Chapter 11 - Managing Network Connections
Configuring Network Interfaces
Managing Network Interface Cards
Managing Network Connections
Checking Name Resolution
Troubleshooting Network Problems
Summary
Chapter 12 - Accessing Network Resources
Transferring Files
Sharing Remote Directories
Chatting with Friends in IRC
Using Text-Based E-mail Clients
Summary
Chapter 13 - Remote System Administration
Remote Login and Tunneling with SSH
Using screen: A Rich Remote Shell
Using a Remote Windows Desktop
Using Remote Desktop and Applications
Sharing Your Desktop Using VNC
Summary
Chapter 14 - Locki ng Down Security
Working with Users and Groups
Managing Users the GUI Way
Checking on Users
Configuring the Built-in Firewall
Working with System Logs
Summary
A - Using vi or Vim Editors
B - Special Shell Characters and Variables
C - Personal Configuration Files
D - AppleScript Command Summary
E - Fink Package Summary
F - Perl Primer
Index
Mac OS® X UNIX® Toolbox: 1000+ Commands for Mac OS® X Power Users
Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
eISBN : 978-0-470-54940-7
Library of Congress Cataloging-in-Publication Data
Myer, Thomas.
Mac OS X UNIX toolbox : 1000+ commands for Mac OS X power users / Thomas Myer, Christopher Negus, François. Caen. p. cm.
1. Mac OS. 2. UNIX (Computer file) 3. Macintosh (Computer)--Programming. I. Negus, Chris, 1957- II. Caen, François. III. Title.
QA76.76.O63M926 2009005.4’46--dc22
2009001890
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Mac OS is a registered trademark of Apple, Inc. All other trademarks are the property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
To Hope, for loving me anyway.
—Thomas Myer
About the Authors
Thomas Myer currently resides in Austin, Texas, where he runs Triple Dog Dare Media, a consulting group that builds CodeIgniter applications, writes technical documentation and copy, and works as a systems analyst for hire. He is the author of Lead Generation on the Web, No Nonsense XML Web Development with PHP, Professional CodeIgniter, and From Geek to Peak: Your First 365 Days as a Technical Consultant, as well as dozens of articles on technology and business. If you have any feedback on this book, or wish to discuss anything related to Web development, writing, or marketing, contact him via his website at www.tripledogs.com.
Christopher Negus is the author of the Fedora and Red Hat Linux Bibles, as well as BSD UNIX Toolbox. Chris served for eight years on development teams for the UNIX operating system at AT&T, where UNIX was created and developed.
François Caen, through his company Turbosphere LLC, hosts and manages business application infrastructures, 95 percent of which run on Linus systems.
Credits
Acquisitions EditorJenny Watson
Development EditorWilliam Bridges
Technical EditorBrian Joseph
Production EditorDaniel Scribner
Copy EditorLuann Rouff
Editorial ManagerMary Beth Wakefield
Production ManagerTim Tate
Vice President and Executive GroupPublisherRichard Swadley
Vice President and Executive PublisherBarry Pruett
Associate PublisherJim Minatel
Project Coordinator, CoverLynsey Stanford
CompositorJeff Lytle, Happenstance Type-O-Rama
ProofreaderPublication Services, Inc.
IndexerMelanie Belkin
Acknowledgments
I would like to acknowledge all the work done by the developers, project managers, analysts, and others on the Mac OS X team. They’ve created something wonderful in this stable, secure, and speedy little OS. I’ve had a great deal of fun and joy working with it, which is more than most people can say when it comes to computing.
Special thanks to Jenny Watson for being such a joy to work with. Even more thanks to Bill Bridges, who took my calls, answered my questions, and kept things moving forward even when it looked like we were going to become permanently stuck in the weeds.
I wouldn’t have been able to work on this book if it weren’t for my ever-loving and ever-patient wife, Hope. Your name says it all—you fill my life with hope and joy and love and…well, everything. Thanks for being such a champ.
—Thomas Myer
Introduction
Mac OS X UNIX Toolbox is loosely based on the BSD UNIX Toolbox written by Chris Negus and François Caen. When I was asked by Wiley to extend what they had done into the world of Mac OS X, I heartily agreed to do so, partly because the original was such an excellent resource.
From the very beginning, I decided to keep to the spirit and structure of the original title as much as I could. Thankfully, about 90 percent of what you experience UNIX-WISE on Mac OS X is the same as on BSD or Linux environments, so I was able, for the most part, to abide by this agreement. In some cases, though, I had to nip and tuck a few sections; in others, I had to add a bit back in.
At the end of the day, what you hold is a handbook with more than 1,000 specific command lines to help you become a Mac OS X power user. Whether you are a systems administrator or desktop user, the book will show you commands to create file systems, troubleshoot networks, lock down security, and dig out almost anything you care to know about your Mac OS X system.
Of course, Mac OS X being what it is, not everything in this book is about the command line (although most of it is). In some cases, I show you not only how to do things on the venerated command line, but also how to take advantage of the Mac OS X GUI. Either way, you learn how to leverage UNIX to do your job.

Who Should Read This Book

This book is for anyone who wants to access the power of a Mac OS X system as a systems administrator or user. You may be a free and open-source software (FOSS) enthusiast, a UNIX professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by BSD, Linux, and Mac OS X systems.
The bottom line is that you want to find quick and efficient ways of getting Mac OS X systems working at peak performance. These may be a few desktop systems at work, a file and print server at your school, or a home web server that you’re setting up mostly for fun.
In the best case, you should already have some experience with BSD, Linux, or other UNIX-like systems. However, if you are a computer professional with skills managing other types of operating systems, such as Windows, you should be able to leverage your knowledge and use the specific commands covered in the book.

What This Book Covers

I assume that you’re new to Mac OS X, but that you’re coming to that platform from some other UNIX platform, such as Linux or BSD. In other words, I assume that you know something about the command line, but don’t yet know the Mac OS X Way. I will show you that way, pointing out how to get to the shell, how to run commands, and how things (most of which you may take for granted) have changed from one flavor of UNIX (i.e., the one you’re used to) to Mac OS X’s flavor of UNIX. The book will then supplement that knowledge with information you need to do the following activities:
• Get software—Mac OS X can be extended using various package managers. Using these package managers, you can install both binary packages and source code. I will introduce you to Fink, which you’ll use to find, download, install, and manage software from the command line.
• Access applications—Find what’s available from the Mac OS X distribution.
• Use the shell—Find neat techniques and tips for using the shell.
• Play with GUI tools—Use the command-line options to run products such as iTunes, TextEdit, and Safari.
• Work with files—Use, manipulate, convert, and secure a wide range of file types in Mac OS X.
• Administer file systems—Access, format, partition, and monitor your file storage hardware (hard disks, CD/DVD drives, floppy disks, USB flash drives, and so on). Then create, format, and check the file systems that exist on those hardware devices.
• Back up and restore data—Use simple commands to gather, archive, and compress your files into efficient backup archives. Then store those archives locally or on remote computers.
• Work with processes—List running processes in a variety of ways, such as by CPU use, processor use, or process ID. Then change running processes to have them run in the background or foreground. Send signals to processes to have them reread configuration files, stop and resume processing, or stop completely (abort).
• Manage the system—Run commands to check system resources, such as memory usage, run levels, and more.
• Monitor networks—Bring wired and wireless network connections up and down. Check routing, DNS, and host information. Keep an eye on network traffic.
• Get network resources—Connect to UNIX and Windows remote file systems using FTP, NFS, and Samba facilities.
• Do remote administration—Access and administer other computers using remote login (ssh, telnet, and so on) and screen. Learn about remote administration interfaces, such as SWAT and CUPS.
• Lock down security—Set up firewalls and system logging to secure your Mac OS X systems.
• Get reference information—Use the appendixes at the end of this book to get more information about the shell (such as metacharacters and shell variables) and personal configuration files.
If we’ve done it right, it will be easier to use this book than to Google for the command lines or GUI tools you need.
After you’ve mastered many of the features described in this book, you’ll have gained the following advantages:
• Hundreds of commands—By compressing a lot of information into a small space, you will have access to hundreds of useful commands, in over 1,000 command lines, in a handy form to carry with you.
• Transferable knowledge—Most of the same commands and options you use in Mac OS X systems will work exactly the same way on other UNIX-like systems. Different UNIX systems, however, offer different graphical administration tools; and even within a particular distribution, graphical tools change more often than commands do.
• Quick problem solving—By the time others have started up a desktop and launched a graphical administration tool, you will have already run a half dozen commands and solved the problem.
• Enduring value—Many of the commands described in this book were used in early UNIX systems, so you are gaining tools that reflect the experience of thousands of computer experts for more than 30 years.
Because the full documentation for commands used in Mac OS X systems consists of thousands of man pages, info text, and help messages, you will surely want to reach beyond the pages of this book from time to time. Luckily, Mac OS X and other UNIX systems include helpful information installed on the system itself. Chapter 1 contains descriptions of how to access this information, which is probably already installed, or can be easily installed, on your system.

How This Book Is Structured

This book is neither a pure reference book (with alphabetically listed components) nor a guide (with step-by-step procedures for doing tasks). Instead, the book is organized by topic, and includes the most useful commands and options you will likely work with.
Chapter 1 provides you with a basic understanding of what Mac OS X is and how it relates to the operating systems that are derived from BSD, such as FreeBSD, NetBSD, and OpenBSD. Then it describes some of the vast resources available to support your experience with this book, such as man pages, info material, and help text. Chapter 2 provides a quick overview of the Mac OS X environment and how you can set it up to get easy access to UNIX tools. It also includes a quick introduction to Fink, a package manager that will enable you to install additional tools mentioned in this book.
Chapters 3, 4, 5, and 6 describe commands that a regular user may find useful on Mac OS X systems. Chapter 3 describes tools for using the shell, Chapter 4 covers commands for working with files, and Chapter 5 describes how to manipulate text. Chapter 6 walks you through more advanced shell scripting and introduces AppleScripting.
Starting with Chapter 7, we get into topics relating to system administration. Creating and checking file systems is covered in Chapter 7, while commands for doing data backups are described in Chapter 8. Chapter 9 explains how to manipulate running processes, and Chapter 10 describes administrative tools for managing basic components, such as hardware modules, CPU use, and memory use.
Chapter 11 begins the chapters devoted to managing network resources by describing how to set up and work with network interfaces. Chapter 12 covers text-based commands for file transfer, file sharing, chats, and e-mail. Tools for doing remote system administration are included in Chapter 13.
Chapter 14 covers how to lock down security, using features such as firewalls and logging. Following that are six appendixes that provide additional reference information for text editing, shell features (metacharacters and variables), personal configuration files, AppleScript commands, a quick Perl primer, and some interesting packages available via Fink that you might want to explore.

What You Need to Use This Book

This is definitely not a book you curl up with on your next vacation. Nor is it meant to entertain you. Throughout, I fully expect you to be sitting in front of a Mac OS X system, scratching your head with one hand and holding this book in the other, looking for a solution.
In other words, the book is meant to be a companion as you work on a problem related to Mac OS X. You’ll probably be working on a desktop system at home or work, but a fair number of you will be working on a file, web, or print server running Mac OS X.
All the commands in this book have been tested against a 64-bit x86 system running Mac OS X 10.5 (Leopard). Specifically, I’m running a MacBook Pro. My technical editor checked everything on a MacBook Pro (running Mac OS X 10.5) primarily, but he also used a MacBook (running Mac OS X 10.5) and (once) a PowerMac (running Mac OS X 10.4).
I assume that you’re running Leopard, but don’t despair if you’re on Tiger, as most of what is covered here also pertains to that earlier release. In addition, please note that nearly every command available from the shell has been around for a long time (some dating back more than 30 years to the original UNIX days), and most will work exactly as described here on NetBSD, OpenBSD, and other derivative systems, regardless of CPU architecture.
Furthermore, many of the commands described in this book will also work on other UNIX and Linux systems. Because this book focuses on Mac OS X, descriptions will differ from other UNIX-like systems most prominently in the areas of packaging, installation, and GUI administration tools.

Conventions

To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book. In particular, we have created styles for showing commands that allow us to fit as many command lines as possible in the book.
With command examples, computer output (shell prompts and messages) is shown in regular monospace font, computer input (the stuff you type) is shown in bold monospace font, and a short description (if included) appears in italics. Here is an example:
To save space, output is sometimes truncated (or skipped altogether). Three dots (…) are sometimes used to indicate that additional output was cut. If a command is particularly long, backslashes will appear at the end of each line to indicate that input is continuing to the next line, as shown here:
In the preceding example, you can type the backslashes to have all that information included in the single command; or you can simply put all the information on a single line (excluding the backslashes). Note that command prompts are shown in one of two ways:
As noted, when a dollar sign prompt ($) appears, any user can run the command. With a pound sign prompt (#), you probably need to be the root user in order for the command to work.
Notes and warnings appear as follows:
Warnings and notes are offset and placed in italic like this.
As for styles in the text:
• We highlight new terms and important words with italic when we introduce them.
• We show keyboard strokes like this:N or Ctrl+N.
• We show filenames, URLs, and code within the text like so: persistence. properties.
One final technique used in this book is to highlight text that describes what an upcoming command is meant to do. For example, we may say something like “use the following command to display the contents of a file.” We’ve styled descriptions in this way to provide you with quick visual cues, so you can easily scan the page for that command you just knew had to be there.
1
Starting with UNIX on Mac OS X
IN THIS CHAPTER
Finding Mac OS Xresources
Quick and powerfulcommands
Handy references to manyuseful utilities
Working as Mac OS Xgurus do
Are you an old hand at the Mac? Do you use the underlying UNIX just once in a while? Many times a day? Never heard of it? Regardless of your skill level, a book that presents efficient ways to use, check, fix, secure, and enhance UNIX on Mac OS X can be an invaluable resource.
Mac OS X UNIX Toolbox is that resource.
Mac OS X UNIX Toolbox is aimed primarily at Mac OS X power users and systems administrators. To give you what you need, we tell you how to quickly locate and get software, monitor the health and security of your systems, and access network resources. In short, we cut to the most efficient ways of using UNIX systems.
Our goal with Mac OS X UNIX Toolbox is to pack a lot of useful information for using UNIX tools and systems into a small package that you can carry around with you. To that end, we describe the following:
• Commands—Tons of command-line examples to use BSD systems in helpful and clever ways
• GUI tools—Quick pointers to graphical administration tools to configure your system
• Software packages—Short procedures to find and download tons of applications
• Online resources—Listings of the best locations to find BSD forums, mailing lists, IRC channels, and other online resources
• Local documentation—Tools for gathering more information from man pages, doc directories, help commands, and other resources on your BSD system
Because you’re not a beginner with Mac OS X, you won’t see a lot of screenshots of windows, icons, and menus. What you will see, however, is the quickest path to getting the information you need in order to use UNIX on Mac OS X to its fullest extent.
If this sounds useful to you, please read on.

About FreeBSD, NetBSD, and OpenBSD

Mac OS X is a modern operating system that combines the power of a UNIX-based operating system and the simplicity and elegance of the Macintosh UI. Its open-source core, called Darwin, is a direct descendant of various BSD projects. It is based in part on BSD 4.4 Lite, but many libraries and utilities are from FreeBSD and NetBSD. Because of this history, it’s useful to delve into the history of BSD.
In the early 1970s, AT&T released the UNIX source code to several colleges and universities, allowing them to begin changing, adapting, and improving that code as they pleased. That decision has led to the development of every major free and open-source software operating system today, not the least of which are the systems based on the Berkeley Software Distribution (BSD).
The twisty history of BSD is easy to Google, if you care to learn the details. For our purposes, here are the highlights:
• BSD began as a set of software add-ons to AT&T’s Sixth Edition UNIX.
• Over the years, BSD developers split off on their own development path, rewriting software with the intention of replacing all AT&T copyrighted code.
• In the early 1990s, AT&T’s UNIX System Laboratories sued BSD developers (Berkeley Software Design, Inc.) for copyright infringement.
• Although the lawsuit was eventually settled (with only a few files needing to be changed from the BSD code), the Linux operating system was able to become a leader of open-source software development while questions surrounding how free BSD was were being threshed out.
• In 1995, the final version of BSD from Berkeley was released under the name 4.4BSD-Lite, release 2. Today’s BSD operating systems, including FreeBSD, NetBSD, and OpenBSD, are all based to some extent on 4.4BSD-Lite.
Operating systems derived from BSD have a well-earned reputation for stability and security. BSD was developed at a time when computing resources (disk space, network bandwidth, and memory) were meager by today’s standards, so BSD systems were operated by efficient commands, instead of the bloated applications and dumbed-down graphical interfaces often seen today.
Because of the nature of BSD systems, people running those systems required a high level of expertise. Even when simplified graphical user interfaces based on the X Window System began to appear, to effectively operate a BSD system you still needed to know about such things as kernels, device drivers, modules, and daemons. Because security came before ease of use, a BSD expert would need to know how to deal with the fact that many features you might want are not installed or are turned off by default.
If you are someone who has used Linux before, transitioning to a BSD system shouldn’t be too hard. However, BSD systems tend to behave a bit more like older UNIX systems than they do like Linux. Many interfaces are text-based, offering a lot of power if you know what you are doing. Despite that fact, however, all the major desktop components that, for example, you get with the GNOME desktop environment are available with BSD systems, so you don’t have to live on the command line.
Here is a list of popular BSD-based operating systems still being developed today:
• FreeBSD (www.freebsd.org) is the most popular of the BSD operating system distributions. It can be operated as a server, workstation, or desktop system, but has also been used in network appliances and special-purpose embedded systems. It has a reputation for maximum performance.
• NetBSD (www.netbsd.org) has a reputation for being very portable, with versions of NetBSD running as an embedded system on a variety of hardware. NetBSD can run on anything from 32-bit and 64-bit PCs to personal digital assistants (PDAs) to VAX minicomputers.
• OpenBSD (www.netbsd.org) is a popular system for network servers, although it can operate as a workstation or network appliance as well. The goal of OpenBSD is to attain maximum security. Unlike FreeBSD and NetBSD, which are covered under the BSD license, OpenBSD is covered primarily under the more permissive Internet Systems Consortium (ISC) license.
• DragonFly BSD (www.dragonflybsd.org) was originally based on FreeBSD. Its goal was to develop technologies different from FreeBSD in such areas as symmetric multiprocessing and concurrency. Therefore, the focus has been on expanding features in the kernel.
Other free (as in no cost, as well as freedom to do what you like with the code) operating systems based on BSD include Darwin (on which Mac OS X is based) and the desktop-oriented systems PC-BSD and DesktopBSD. FreeSBIE is a live CD BSD system. Proprietary operating systems that have been derived from BSD include the following:
• Mac OS X (www.apple.com/macosx) is produced by Apple, Inc., and is focused on providing an easy-to-use graphical interface to sell with its line of computers. There is also a Mac OS X Server product available. Although Mac OS X was originally based on Darwin, it is considered a closed-source operating system with open-source components.
• SunOS (www.sun.com) was developed by Sun Microsystems and was very popular as a professional workstation system. Sun stopped development of SunOS in favor of Solaris. However, because Solaris represented a merging of SunOS and UNIX System V, many BSD features made their way into Solaris
You can find a longer list of BSD distributions at the DistroWatch site (http://distrowatch.com/search.php?category=BSD). Besides offering descriptions of those BSD distributions, you can also find links to where you can purchase or download the software.

Finding Mac OS X Resources

The best place to find Mac OS X resources is at www.apple.com/macosx/. There you’ll find guided tours, documentation, and links to the Developer Connection (developer.apple.com).
Apple’s Developer Connection is an invaluable resource for anyone contemplating more advanced development work, either in Mac OS X or the iPhone. Membership in the Developer Connection program gives you access to pre-release software and technical support, as well as a complete set of resources for developing tools.
Although much of the information provided in the Developer Connection area is not specific to UNIX (as it involves programming in Carbon or Objective-C), having access to the information and community of developers is a good thing overall.

Focusing on Mac OS X Commands

Many important tasks on Mac OS X can be done from both the graphical interface and the command line. However, the command line has always been, and still remains, the interface of choice for UNIX power users.
Graphical user interfaces (GUIs) are meant to be intuitive. With some computer experience, you can probably figure out, for example, how to add a user, change the time and date, and configure a sound card from a GUI. For these cases, we’ll mention which graphical tool you could use for the job. For the following cases, however, you will probably need to rely on the command line:
• Almost anytime something goes wrong—Ask a question at an online forum to solve some UNIX problem you are having and the help you get will almost always come in the form of commands to run. In addition, command-line tools typically offer much more feedback if there is a problem configuring a device or accessing files and directories.
• Remote systems administration—If you are administering a remote server, you may not have graphical tools available. Although remote GUI access (using X applications or VNC) and web-based administration tools may be available, they usually run more slowly than what you can do from the command line.
• Features not supported by GUI—GUI administration tools tend to present the most basic ways of performing a task. More complex operations often require options that are only available from the command line.
The bottom line is that in order to unlock the full power of your Mac OS X system, you must be able to use shell commands. Thousands of commands are available to monitor and manage every aspect of your system.
Whether you are a UNIX guru or a novice, however, one challenge looms large: How do you remember the most critical commands and options you need, when a command shell might only show you this:
$
Mac OS X UNIX Toolbox is not just another command reference or rehash of man pages. Instead, this book presents commands on Mac OS X according to how you actually use them. In other words, instead of listing commands alphabetically, we group together commands for working with file systems, connecting to networks, and managing processes, so you can access commands by what you want to do, not only by how they are named.
Likewise, we won’t just give you a listing of every option available for every command. Instead, we provide working examples of the most important and useful options to use with each command. From there, we’ll describe quick ways to find more options, if you need them, from man pages, the info facility, and help options.

Finding Commands

All the commands described in this book should be installed when you are ready to run them. However, note that this book is based on the latest release of Mac OS X (version 10.5, called Leopard), so if you are running Tiger (10.4) you may not have something installed.
You might type a command and see a message similar to the following:
This might happen for the following reasons:
• You mistyped the command name.
• The command is not in your PATH.
• You may need to be the root user for the command to be in your PATH.
• The command is not installed on your computer.
Table 1-1 shows some commands you can run to look for a command you want to use.
Table 1-1: Finding Commands
If you suspect that the command you want is not installed, the best remedy is probably to upgrade to the latest version of Mac OS X.

Command Reference Information in UNIX

Original BSD, Linux, and UNIX documentation was all done on manual pages, generally referred to as man pages. A slightly more sophisticated documentation effort appeared a bit later with the info facility. Within each command itself, help messages are almost always available.
This reference information is component oriented—in other words, there are separate man pages for nearly every command, file format, system call, device, and other component of a BSD system. Documentation more closely aligned to whole software packages is typically stored in a subdirectory of the /usr/local/share/doc directory.
All three reference features—man pages, info documents, and help messages—are available in BSD systems.

Using help Messages

The -h or --help options are often used to display help messages for a command. The following example illustrates how to display help for the man command:
The preceding output shows how the man command line is used and lists available options.

Using man Pages

Suppose you want to find man pages for commands related to a certain word. Use the apropos command to search the man page database. This shows man pages that have crontab in the man page NAME line:
The apropos output here shows each man page NAME line that contains crontab. The number shows the man page section in which the man page appears. (We discuss sections shortly.)
The whatis command is a way to show NAME lines alone for commands that contain the word you enter: