Site Contents
About the Book Introduction to the Book The 101 Projects Supplementary Material Code to Download ErrataAbout the Book
Lose the mouse and start taking advantage of the power of Mac OS X's Unix core.
Welcome to the web site for the book Mac OS X Unix, 101 Byte-Sized Projects by Adrian Mayo and published by InsideMac Press and Peachpit Press.
In this practical and approachable book, Adrian guides readers through 101 compact and essential Unix projects filled with tips and advice. You'll learn Unix through doing, and you'll learn how to apply Unix to solve real-world problems. Newcomers will gain a useful knowledge of Unix, while those already familiar with the command line will expand their skills.
Whether it's to search for files, search and automatically edit file content, use regular expressions, mount disks and network shares, create user accounts, configure Apache, write shell scripts to automate tasks, or any one of 94 other tasks, you'll find a project that shows you how.
This site reproduces the book's introduction and lists the 101 projects. It presents supplementary material for particular projects, written in response to readers' feedback. Example code is available for downloading to save you from typing. See the Site Contents to the left.
If you spot an error, require help in completing a particular project, have any suggestions or contributions to add to the supplementary material, contact Adrian.
Introduction to the Book
This book is for you if you have a problem to solve or a task to complete: Working at the Unix command line often provides the quickest and easiest solution. Although a modern Unix environment such as Mac OS X provides a graphical method of working, the real power still lies at the Terminal and in typing commands. The Unix command line lets you work with your Mac in ways that are difficult or even impossible graphically, unlocking the hidden workings of Apple's OS and unleashing a wealth of powerful free software. Clicking a button may be an easy way to perform a pre-packaged action, but it doesn't give you the expressive power of a set of written commands.
Here's a sample page taken from the book.
Philosophy
Plenty of books teach Unix theory, covering a single subject like Unix itself, the Bash shell, shell scripting, the vim or emacs text editor, the awk text processing language, the Apache web server, networking, firewalls, etc. That's a lot of books, a lot of reading, and a lot of theory. Ninety percent of you don't have the inclination or time to follow that route. You learn on-demand and want to cut to the chase to get a specific job done. You want to focus on the micro-topic that solves your current problem or gives you the knowledge to work out your own solution. Moreover, because most solutions involve more than a single command, you want to know of the relevant techniques, technologies, and commands, and how to use them in combination.
These considerations lead to the book's approach. For 101 of the most common tasks, it explores the most appropriate commands and shows how to use and combine them in the context of the task. This is different from the traditional theory approach that considers a command in its own right and then asks, What can I do with this command?
The book uses a 90:10 philosophy. Ninety percent of the usefulness of a tool or technology lies in just ten percent of its functionality. Awk (a text processing language) is a good example - very powerful and commonly used, but rarely stretched beyond its ten percent headline functionality. By taking the 90:10 approach, we combine ten books in one, illustrate a broad range of topics that you'll encounter every day, and show techniques used in combination, not isolation.
But I Love my Mouse
Mac OS X provides a powerful and elegant graphical user interface, so you might find it counterintuitive to drop into the Unix command line to get a job done. But as with a powerful car, sometimes you need to get under the hood to squeeze out all the performance it can deliver.
Even if you don't have an immediate need, working through some of the projects in this book is a Unix analog to the pointing, clicking, and dragging way in which most of us learned the Mac OS. It'll help you gain familiarity and confidence in using Unix. When you've made friends with the man pages, practiced stringing commands together, written a few scripts, you'll begin to know and appreciate the power under the Aqua-colored hood.
What You'll Learn
You'll learn how to apply Unix and achieve results. Along the way, you'll learn Unix commands, techniques, and technologies. Basic Unix is covered in Chapter 1.
From the 101 projects in this book you'll learn how to:
- Locate then edit many files automatically
- Find files and commands anywhere in the file system as you can with Apple's Spotlight, and process them at the same time.
- Write shell scripts that execute a series of commands automatically
- Search file content for particular text or patterns of text
- Use the Unix manual to full effect to learn about new commands and technologies
- Manage your Mac's hardware, software, user accounts, and network settings
- Mount local disc drives, removable media, and shares from other machines
- Use and customize the Bash and Tcsh shells - the Unix equivalent to using and customizing your desktop and the Finder
- Display, edit, sort, compare, compress, and archive files
You'll also learn techniques and technologies such as:
- Globbing and pattern matching operators that allow you to select many files at once, like all JPEG files or all files starting letter-to
- Scripting commands such as sed and awk to search for and transform the text content of files
- Redirection and pipelining that enable you to save the results of commands and use commands in combination
- Users, groups, and Unix file permissions that protect both your files from unauthorized access by other users, and the system files from being deleted or damaged
- Hard and soft links, which are like Mac OS aliases
- Regular expressions written to describe patterns of text for which you can search
- Unix text editors
- Scheduling and periodic maintenance to automatically perform particular tasks at specified times
- Server technologies such as the Apache web server, Unix Network File System (NFS) for sharing files with other Unix machines, File Transfer Protocol (FTP) for transferring files between computers, and the Domain Naming System (DNS) that translates names such as www.apple.com into Internet Protocol addresses (IP addresses)
The 101 Projects
Here's a list of the 101 projects. Although they can be read sequentially, the book was written for "random access". You'll probably pick it up when you seek a solution to a problem. Each chapter groups projects that cover similar tasks, so to find a suitable project start with the Table of Contents and choose the chapter that seems closest to your task. Scan the list of projects in the chapter and choose the project that looks like the closest fit. Then read the introduction to confirm it's the right one; each project introduction starts with a typical question that the project will answer, and then outlines the material it covers.
Table of Contents
Chapter 1: Absolute Basics
Chapter 2: Browse and Search the File System
Chapter 3: Work with File Content
Chapter 4: Edit Files
Chapter 5: Keep an Eye on Your Mac
Chapter 6: Make the Most of the Shell
Chapter 7: Programmatically Change Files
Chapter 8: Administer the System
Chapter 9: Learn Shell Scripting
Chapter 10: Network in Unix
Chapter 11: Discover More Commands
Appendix: Unix Terminology Reference
Supplementary Material
This section presents supplementary material for some of the projects. It includes explanatory text to supplement that in the book, extra examples, clarifications of the book text, and corrections. (See also Errata.)
The material is written in response to readers' feedback. If you spot an error, require help in completing a particular project, have any suggestions or contributions to add to the supplementary material, then email Adrian using the contact link to the left.
To see supplementary information for a project, select it from the list below.
(There's no supplementary material at the moment.)
Code to Download
To save you from typing you may download the code extracts presented in the book. Click to download a zipped tar file. To extract it, change to the directory containing the download and type:
$ tar -xzf 101-downloads.tgzThis will create a directory called 101-downloads. In this directory you'll find many of the code extracts used throughout the book. Each file is named according to the project and example to which it pertains.
You'll also find Bash configuration files which contain settings used and suggested in the book. Copy these files to their proper places to try them out (but make sure you backup the originals first), then start a new Bash shell.
The Bash configuration files are:
- profile (copy to /etc/profile)
- bashrc (copy to /etc/bashrc)
- dot-bash_profile (copy to ~/.bash_profile)
- dot-bashrc (copy to ~/.bashrc)
The file dot-bashrc contains aliases and functions suggested throughout the book, grouped by project number.
Errata
Here's a list of the known errors. If you spot an error, email Adrian using the contact link to the left. If you would like to see additional explanatory information on any of the projects, or require help, see Supplementary Material.
(There's no errata, so far...)