Medium 9780596009151

Learning Unix for Mac OS X Tiger

Views: 676
Ratings: (0)

Beneath Mac OS X Tiger's easy-to-use Aqua interface lies a powerful Unix engine. Mac users know that Unix is at their fingertips, if only they knew how to access it. Learning Unix for Mac OS X Tiger provides Mac users with a user-friendly tour of the Unix world concealed beneath Mac OS X's hood and shows how to make the most use of the command-line tools.

Thoroughly revised and updated for Mac OS X Tiger, this new edition introduces Mac users to the Terminal application and shows you how to navigate the command interface, explore hundreds of Unix applications that come with the Mac, and, most importantly, how to take advantage of both the Mac and Unix interfaces. Readers will learn how to:

  • Launch and configure the Terminal application
  • Customize the shell environment
  • Manage files and directories
  • Search with Spotlight from the command line
  • Edit and create text files with vi and Pico
  • Perform remote logins
  • Access internet functions, and much more
Learning Unix for Mac OS X Tiger is a clear, concise introduction to what you need to know to learn the basics of Unix on Tiger. If you want to master the command-line, this gentle guide to using Unix on Mac OS X Tiger is well worth its cover price.

List price: $15.99

Your Price: $12.79

You Save: 20%

Remix
Remove
 

11 Slices

Format Buy Remix

1. Why Use Unix?

ePub

Why would any sane person want to type in a bunch of funny looking Unix commands when you can just use the mouse? After all, Mac OS X has oneif not the best looking user interface out there, so what would compel you, a Mac user through and through, to use the Unix command line? That's a tough sell, but you can boil it down to just one word: Power.

Lying underneath Mac OS X Tiger's purring Aqua interface is a powerful Unix system, ready to leap into action at a moment's notice. All you have to do is command Unix to take action. One of the greatest pleasures of using Unix within Mac OS X is that you get the benefit of a truly wonderful graphical environment and the underlying power of the Unix command line. There's no denying it's a match made in heaven. Even Apple promotes Mac OS X with the tagline:

This chapter sets the stage for the rest of the book, answering the question: "Why use Unix when you have a perfectly good Mac graphical interface?" It's an important question, and I think that within just a few minutes, you'll agree that joining the Unix world is really like learning you have a completely separate, and even more powerful, operating system lurking in your machine.

 

2. Using the Terminal

ePub

With a typical Unix system, a staff person has to set up an account for you before you can use it. With Mac OS X, however, the operating system installation process automatically creates a default user account. The account is identified by your username, which is usually a single word or an abbreviation. Think of this account as your officeit's your personal place in the Uix environment.

When you log into your Mac OS X system, you're automatically logged into your Unix account as well. In fact, your Desktop and other customized features of your Mac OS X environment have corresponding features in the Unix environment. Your files and programs can be accessed either through the Finder or through a variety of Unix command-line utilities that you can use in Mac OS X's Terminal application.

In this chapter, you'll not only learn about the Terminal and how to customize it for your own needs, but you'll also gain an understanding of the command-line nature of Mac OS X when accessed through the Terminal. If you're used to moving your mouse around and clicking on buttons, this might seem wonderfullyor awkwardlyretro, but like any other powerful environment, the difference between the Finder and the Terminal are part of what makes the Terminal, and Unix, so remarkably powerful.

 

3. Exploring the Filesystem

ePub

Once you launch the Terminal, you can use the many facilities that Mac OS X provides at the command line, an environment that's quite a bit more powerful than the graphical interface you may be used to viewing. As a user, you have an account that gives you:

A place in the filesystem where you can store your files

A username that identifies you and lets you control access to files

An environment you can customize

In this chapter, you'll see how all the thousands of files on your Mac are organized, how to learn more details about any given file, and how to move around through Mac OS X's filesystem. You'll see that the Finder has been hiding quite a lot of information from you, entire directories with thousands of files that are invisible from the Finder but easily found and explored within the Terminal.

A file is the unit of storage in Mac OS X. A file can hold anything: text (a report you're writing, a to-do list), a program, digitally encoded pictures or sound, and so on. All of those are just sequences of raw data until they're interpreted by the right program.

 

4. File Management

ePub

The previous chapter introduced the Unix filesystem, including an extensive discussion of the directory structure, the ls command for seeing what files are on your system, and how to move around using cd and pwd. This chapter focuses on Unix filenaming schemeswhich aren't the same as names you'd see in the Finder, as you'll seeand how to view, edit, rename, copy, and move files.

As Chapter 3 explained, both files and directories are identified by their names. A directory is really just a special kind of file, so the rules for naming directories are the same as the rules for naming files.

Filenames may contain any character except /, which is reserved as the separator between files and directories in a pathname. Filenames are usually made of upper- and lowercase letters, numbers, dots (.), and underscores (_). Other characters (including spaces) are legal in a filename, but they can be hard to use because the shell gives them special meanings or otherwise forces you to constantly be changing how you work with these filenames on the command line.

 

5. Finding Files and Information

ePub

One of the fundamental challenges with modern computers is finding files and information. Whether you're highly organized and use wonderfully mnemonic names for every file or directory created, or whether you have lots of letter1, letter2, and work directories scattered around your filesystem, there will undoubtedly come a time when you need to find something on your computer based on its contents, filename, or similar attribute.

It turns out that there are four different ways in Unix to search forand hopefully findwhat you seek. To look inside files, you need to use the grep command, as introduced briefly in the previous chapter. To find files by filename, the fastest solution is the locate command. A more sophisticated filename and attribute search can be done with the Unix power-user's find command. And finally, Tiger introduces an entirely new search system called Spotlight that has a powerful command-line component worth exploring.

The grep program searches the contents of files for lines that have a certain pattern. The syntax is:

 

6. Redirecting I/O

ePub

Many Unix programs read input (such as a file) and write output in a standard way that lets them work with each other. This exchange of information is commonly known in Unix circles as I/O (pronounced "eye-oh," which is short for input/output). In this chapter, we discuss some of these tools and learn how to connect programs and files in new and powerful ways.

This chapter generally doesn't apply to programs such as the vi editor, that take control of your entire Terminal window. (less does work in this way, however.) It also doesn't apply to graphical programs that open their own windows on your screen, such as iTunes or Safari. On the other hand, the vast majority of Unix commands that you use on the command line are line oriented, and they're exactly why I/O redirection is included in Mac OS X's Unix.

The difference between screen oriented and line oriented is a bit tricky to figure out when you're just starting. Think of it this way: if you can use arrow keys to move up and down lines, then it's a screen-oriented program. The vi editor is the classic example of a screen-oriented program. If the input or output is all shown line by line, as in the ls command's output, then it's a line-oriented command. Almost all Unix commands are line oriented, as you'll see in this chapter.

 

7. Multitasking

ePub

Mac OS X can do many jobs at once, dividing the processor's time between running applications and system processes so quickly that it looks as if everything is running at the same pace. This is called multitasking. As new applications are launched, processes are started, and others go idle or shut down entirely, the system monitors each of these tasks and doles out memory and CPU resources on the fly to make sure everything is running smoothly.

For most users, we think of multitasking in the way Mac OS X handles applications like Adobe Photoshop, Microsoft Word, Mail, iChat, Safari, etc.allowing you to have multiple applications open, each with its own windows. But on the Unix side, Mac OS X allows you to run multiple Unix programs and/or processes at the same time as well. These processes can be run and monitored all through one single Terminal window, with a little help from something called job control . Even if you're using a window system, you may want to use job control to do several things inside the same Terminal window. For instance, you may prefer to do most of your work from one Terminal window, instead of having multiple Terminal windows open when you really don't need to.

 

8. Taking Unix Online

ePub

A network lets computers communicate with each other, share files, send email, and much more. Unix systems have been networked for more than 25 years, and the Mac OS has had networking as an integral part of the system design from day one. In fact, AppleTalk was the first computer network that let computers connect directly together without needing a server in the middle.

This chapter introduces Unix networking: remotely accessing your Mac from other computers and copying files between computers. It also shows you how the Terminal's "Connect to Server" feature can make common connections a breeze once you've set them up the first time.

There may be times when you need to access your Mac, but you can't get to the desk it's sitting on. If you're working on a different computer, you may not have the time or inclination to stop what you're doing, walk over to your Mac, and log in (laziness may not be the only reason for this: perhaps someone else is using your Mac when you need to get on it, or perhaps your Mac is miles away). Mac OS X's file sharing (System Preferences Sharing Services) lets you access your files, but there may be times you want to use the computer interactively, perhaps to move files around, search for a particular file, or perform a system maintenance task.

 

9. Of Windows and X11

ePub

Mac OS X comes with great applications, and a trip to the Apple Store can bag you quite a few more, but there's a flood of applications available to you solely because of Mac OS X's Unix core. Many of these are applications that have been around for a long time, and many are flowing in from other members of the Unix family, including Linux and FreeBSD.

What's different about these applications is that they're not commercial apps like Microsoft Office or Adobe Photoshop, they're not shareware like Graphic Converter and Fetch, and they're not free, public domain applications either. Most of the programs now available to the Mac community from Unix are part of the open source movement. These applications are free to downloadincluding source code, if you want itbut there are constraints on what you can do with the programs, and if you're a programmer and make any modifications to the source, you have an obligation to share those changes with the rest of the open source community. It's a very different distribution model for software, but don't let the lack of a price tag fool you: open source applications are often just as good (and sometimes better) than their commercial equivalents, and having distributed teams of programmers building the apps means that if you do find a bug and report it, the fix often shows up sometime the same daysomething that Apple and Microsoft certainly can't match.

 

10. Open Source Software Via Fink

ePub

The Fink Project is a mechanism for obtaining, installing , and keeping up to date a wide variety of open source applications on your Macintosh. The project itself is made up of volunteers who are dedicated to bringing the best open source software to Mac OS X. They fine-tune these open source applications for the Mac OS X environment, and then keep the applications updated so they work with the latest release of Mac OS X.

Many of the programs featured in this chapter are available through Fink, as is a wealth of other applications.

Since Fink does not come with Mac OS X, you'll first need to download its disk image from http://fink.sourceforge.net/download. Once you've downloaded and mounted the disk image by double-clicking it, you're ready to install Fink, with the following steps:

Open the mounted disk image in the Finder, and then double-click Fink's Installer package (the Fink 0.7.7 Installer.pkgfile) inside.

Install the application, using all the default configuration options. You will need your administrative password to complete the task.

 

11. Where to Go from Here

ePub

Now that you're almost to the end of this guide, let's look at some ways to continue learning about the Unix side of Mac OS X. Documentation is an obvious choice, but it isn't always in obvious places. You can also learn how to save time by taking advantage of other shell featuresaliases, functions, and scriptsthat let you shorten a repetitive job and "let the computer do the dirty work."

We'll close by seeing how you can use Unix commands on non-Unix systems.

You might want to know the options to the programs I've introduced and get more information about them and the many other Unix programs. You're now ready to consult your system's documentation and other resources.

An excellent first place to seek further information is the Apple Help system included with the Terminal application. Lots of Mac users automatically ignore the Help menu, mainly because Apple's version of "help" in the early days didn't amount to much. But with Mac OS X Tiger, that's a mistake, because therein lies plenty of useful information. Many of the Terminal's Help topics are specifically about the Terminal application itself, but you'll also find plenty of other interesting topics to read about, including:

 

Details

Print Book
E-Books
Slices

Format name
ePub
Encrypted
No
Sku
B000000024828
Isbn
9780596553043
File size
4.13 MB
Printing
Allowed
Copying
Allowed
Read aloud
Allowed
Format name
ePub
Encrypted
No
Printing
Allowed
Copying
Allowed
Read aloud
Allowed
Sku
In metadata
Isbn
In metadata
File size
In metadata