<<

. 3
( 69 .)



>>



Who This Book Is For An Apply It section usually contains a segment of code
that takes the lesson you just learned one step further.
If you are looking for a resource that will help you learn
Apply It sections offer inside information and pointers that
how to maximize the Unix underpinnings of Mac OS X,
can be used to enhance the functionality of your code.
Unix for Mac: Your visual blueprint to maximizing the
foundation of Mac OS X is the book for you.
No prior experience with operating systems is required,
but familiarity with UNIX or Mac is an asset.
An Extra section provides additional information about the
task you just accomplished. Extra sections often contain
interesting tips and useful tricks to make working with
What You Need To Use This Book
Mac OS X easier and more efficient.
To perform the tasks in this book, you need a power PC
running Mac OS X v.10.2. or higher.
The Organization Of This Book
UNIX for Mac: Your visual blueprint to maximizing the
The Conventions In This Book
foundation of Mac OS X contains 18 chapters.
A number of typographic and layout styles have been used
The first chapter, "Get Started with Unix," introduces
throughout UNIX for Mac: Your visual blueprint to
you to the Unix features that are built directly into the
maximizing the foundation of Mac OS X to distinguish
operating system and constitute the foundation on which
different types of information.
all Mac OS X applications run. You can access this
foundation directly by using the terminal application.
Chapter 2, "Work with Files," illustrates how the Unix shell
Courier Font
enables you to move through the file system and access
Indicates the use of Unix commands, scripting commands parts of your hard drive that are unavailable through the
such as shell or Perl commands, source code such as C or Finder.
Java commands, and HTML.




xii
Unix for Mac:
Your visual blueprint to maximizing
the foundation of Mac OS X




Chapter 3, "Work with Directories," shows how you can Chapter 13, "Install and Use Internet Applications," lists
create, delete, move, copy, change, and navigate files and some of the most popular programs that you can
directories. download and install for better access via the shell to the
Internet.
Chapter 4, "Work with Text," demonstrates how you can
extract, view, and compare text files, and to chain text Chapter 14, "Serve Web Pages with Apache," shows you
commands together. how to use the Apache server on your computer to serve
live pages on the Internet, or as your own test bed for Web
Chapter 5, "Work with Text Editors," illustrates how you
site creation.
can edit a text file in Unix, such as an application's
configuration file, a Web page, or a Perl program. Mac OS X Chapter 15, "Work with Perl," shows you how to use Perl
offers three text editors ” pico, vi, and emacs ” for editing for a variety of tasks from system administration to Web
text files. pages. Mac OS X comes with Perl pre-installed.
Chapter 6, "Customize Your Shell," shows you how to Chapter 16, "Run the X Window System," shows you how
configure your terminal shell to fit your preference. to get the advantage of using both Mac and Unix graphical
programs by running an X server with the Mac OS X GUI
Chapter 7, "Work with Processes," demonstrates how you
called Aqua.
can suspend, start, run, kill, list, and monitor processes.
Chapter 17, "Install X Window System Software,"
Chapter 8, "Automate Shell Tasks," illustrates how a shell
introduces you to free alternatives to expensive
script containing a set of instructions is typed in a terminal
commercial software such as the GIMP that provides the
window and executed to form a basic Unix program. You
functions of Photoshop, and Open Office.org that is a free
will also learn how to set scripts to execute at a specific
equivalent of Microsoft Office.
time of day or date using cron.
The final chapter, "Develop Unix Applications," shows you
Chapter 9, "Combine Unix and Aqua," demonstrates how
how to create and run programs in other languages on
you can best take advantage of running Aqua ” OS X
Mac OS X.
GUI ” alongside the Unix command line.
Chapter 10, "Work with Internet Commands," shows how
you can connect to another computer and execute What's On The CD-ROM Disc
commands or download files.
The CD-ROM disc included in this book contains office
Chapter 11, "System Administration Commands," details tools, such as OpenOffice.org, Gimp, XFree, Fink, and
how you can assign yourself as the system administrator of other open source software. See the appendix for more
your system. information on software included on the companion CD.
Chapter 12, "Install Unix Applications," guides you
through the download and installation of programs, some
free and some not, which run on Mac OS X. These are
often downloaded via the Internet, and come as packages
or archives.




xiii
UNIX FOR MAC




INTRODUCTION TO UNIX
For most users, the Unix foundation for Mac OS X operates

Y
ou can get full use out of your Mac OS X computer
behind the scenes; they may use Mac OS X for years without
by learning the ins and outs of the Unix operating
needing to directly access the Unix features described in this
system. Even though you may not know it, you use
book. However, by understanding and using Unix, you can
Unix every time you turn on your Mac OS X computer,
take full advantage of the power of Mac OS X.
because at the core, Mac OS X is Unix.


THE HISTORY OF UNIX

The original version of UNIX was created in the 1960s in saving data, and sending output to a monitor or other
the Bell Labs of AT&T, by researchers who devised a device. On your Apple computer, these functions are
multi-user operating system for large mainframe provided by the Mac OS X operating system, a direct
computers. The role of an operating system like Unix is descendent of the original Unix operating system.
to provide basic functions such as running programs,

BSD Unix System
From AT&T, the Unix system spread to research version of Unix was known as Berkeley Software
universities, that quickly adopted it. The University of Distribution (BSD), and it forms a major branch of the
California, Berkeley, was one of the earliest adopters operating system family tree. The BSD family tree must
and developers of Unix. The staff and students at be an apple tree, because the most recent fruit is Mac
Berkeley added many more features to this ever- OS X, which is based on the BSD Unix system from
evolving operating system. The updated Berkeley Berkeley.

Open Source Free Operating Systems and Applications
Computer programs begin as source code, written in a The most famous open-source software is the free
computer language by programmers. They are then operating system known as Linux. A young, Finnish
transformed into applications that you can run through software developer named Linus Torvalds created Linux
a process called compiling, which translates the source as a version of Unix that could run on Intel-style PCs, as
code into commands that a computer can understand. well as other hardware. In addition to Linux, there are
several free versions of BSD Unix, known as Free BSD,
You do not need the source code to run the program. Open BSD, and Net BSD. Mac OS X is a cousin to these
However, if you have access to the source code, you can free BSD operating systems, but is not itself a free
recreate the application, or change the application by operating system.
modifying the source code. Many commercial
companies do not make their source code public The largest collection of open-source applications
because, if they did, nobody would buy their software. comes from the GNU project, developed by the Free
Other groups make their source code freely available to Software Foundation. GNU is an acronym for GNU's
the public; this is known as open source. Not Unix, and yes, that is self-referential. Many of the
Unix applications that you run are based on GNU code.




2
1
GET STARTED WITH UNIX




MAC OS X AND UNIX

Up to and including Mac OS 9, the Apple operating
system was not based on Unix. There was no Unix code
at the core of Mac OS 9 or earlier systems; instead, they
used an operating system that was developed within
Apple Computer.

Darwin Aqua
When it was time to create the next version of Mac OS, Each time you run Mac OS X on your computer, you are
Apple chose to base it on a BSD Unix foundation, using Aqua. Aqua is the graphical user interface system
modified for the specific needs of Apple. This version of that gives your Macintosh the distinctive look and feel
BSD Unix was called Darwin. Darwin consists primarily of Mac OS X ” the main menu at the top, the Dock,
of the Unix kernel, which is the program that runs and the desktop, the three colored buttons at the upper left
manages all the processes and shells of the operating corner of each window. The Aqua interface lets you
system, along with associated programs and files that point-and-click to run applications. In truth, Aqua is a
make the kernel run. The source code for Darwin is group of applications that run atop the Mac OS X
open and available on the Web from http://developer. foundation of Unix; Aqua starts automatically to provide
apple.com/darwin/, although you will probably never you with the familiar Mac OS X interface, designed for
need to use it. both keyboard and mouse.

Not all the Mac OS X operating system is open source; X Window System
for example, the programs used to create the Mac OS X
The X Window System is another graphical user
desktop and windows, known collectively as Aqua, are
interface system that is used on most computers
not available for free and are only distributed as
running Unix; however, it does not come standard with
compiled applications.
Mac OS X. Although both the X Window System and
Mac OS X contain the letter X, they are not related ”
Shell Commands
the X in X Window System comes from its being a
The original computers that ran Unix were not successor to an earlier window-based system named W,
graphical; windows, drop-down menus, desktops, and and the X in Mac OS X, of course, stands for the Roman
the point-and-click capabilities of the mouse were to numeral ten.
come later. Early versions of Unix were entirely text-
based, taking input solely from the keyboard and Because the X Window System is used on so many
displaying only on the screen, or sometimes just on a other computers, including Linux, BSD, and Solaris
printer. This meant that all Unix programs were text- machines, there are a number of applications written
based, and responded to keystrokes. Users accessed the for the X Window System, most of them open source
operating system through commands given to an and free. You can run X Window System applications on
application called a shell. your Mac OS X computer by installing an application
called an X server, which gives you access to a wide
The Unix operating systems of today can handle variety of X Window System software.
graphics with ease, but underneath the graphical
windows, text still reigns supreme. Your Mac OS X
computer is no exception. In Mac OS X, you enter shell
commands through an application named Terminal.




3
UNIX FOR MAC


START THE TERMINAL APPLICATION
Each Terminal application runs a separate Unix shell. A shell

Y
ou can use the Mac OS X Terminal application to
is an application that sends your commands to the Unix
enter Unix shell commands and to run Unix
system and provides you with the output of those
applications. The name of the Terminal application
commands. The shell starts by printing a welcome message,
refers back to the physical terminal devices that were
then provides a prompt and waits for you to type a
connected to old Unix mainframes. Each terminal consisted
command. The prompt contains the name of your computer
of a keyboard for input and a screen for text output. The
and your short username, as follows:
Terminal application provides the same function, allowing
you to enter your commands through the keyboard and to
[computer:˜] user%
view the output in the Terminal window.
When a Unix shell command is completed, the prompt
The Terminal application comes with the Mac OS X operating
appears again. As you provide commands to the shell, the
system as a utility application. You can find it in the Utilities
output of your commands moves down the Terminal
folder of the Applications folder, by using Finder. Because you
window. Output that scrolls past the top of the window is
are using the Terminal application to run the Unix commands
not lost forever; you can access it by using the scroll bar on
in this book, you want to keep the Terminal handy by setting
the right side of the Terminal window, or by using the page-
it to Keep In Dock. This allows you to launch a Terminal
up and page-down keys.
window from the Dock with a single mouse-click.

You can have several Terminal windows running at once.
You can also switch between Terminal windows by using
the keyboard shortcuts.

START THE TERMINAL APPLICATION
Go




Applications A

<<

. 3
( 69 .)



>>