05.01.2013 Views

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

Mac OS X Leopard - ARCAism

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introducing the Shell<br />

The Terminal application (go ahead, fire it up) is essentially an empty window that can display<br />

and accept text input. In order for you to actually do anything, Terminal must run a shell program<br />

inside of itself. A shell is a specialized application that helps you interact with Darwin; it<br />

shares the same relationship to Darwin that the Finder shares with Quartz. By default, <strong>Leopard</strong><br />

includes five of the most common UNIX shells: Bash, Korn, Bourne, Tcsh, and Zsh (the C shell<br />

is also listed as a shell—however, it is actually a link to Tcsh). Of the six, the shell <strong>Leopard</strong> uses<br />

by default is Bash.<br />

NOTE Originally, <strong>Mac</strong> <strong>OS</strong> X used Tcsh by default, but switched to Bash with the release of<br />

<strong>OS</strong> X 10.3 Panther. If you are new to working with UNIX shells, I’d recommend sticking with<br />

Bash, at least while you are learning. The lessons in this book, unless specifically noted, are all<br />

given using the Bash shell.<br />

The first time you launch Terminal, you’ll be greeted by some text similar to this:<br />

Last login: Tue Sep 5 14:12:26 on ttyp1<br />

<strong>Leopard</strong>:~ scott$ _<br />

The first line tells you when you last logged in to Darwin (even if you’ve never logged in to<br />

Darwin before intentionally, you’ll still get a message saying you did); followed by the default<br />

prompt for Bash. The default prompt (which, like most everything else in Darwin, can be<br />

changed) gives you some important information. First, it gives you the name of your computer,<br />

which is either assigned by your network or taken from the Computer Name field in the system’s<br />

Sharing preference pane. Next, following the :, the prompt gives you your location in the file system<br />

(the ~ is a shortcut representing your home directory). Then the prompt gives you the<br />

username you are logged in as, followed by the $ prompt (which will change to a # if the user is<br />

logged in as the root user, otherwise known as the superuser). Finally, you get the cursor anxiously<br />

waiting your command.<br />

As you will soon see, shells possess some hidden powers that can make your interactions<br />

with Darwin more pleasant and add a new level of power and flexibility to the command line.<br />

Before you look at the shell in more depth, though, you should first learn a bit about the Darwin<br />

file system as well as a few basic Darwin commands (walk before flying and all that).<br />

Moving Around Darwin<br />

One of the first things you need to learn about the shell is how to move around and view the file<br />

system. To do this, there are three basic commands to start with: ls, cd, and pwd.<br />

ls<br />

ls is the “list” command, and by default lists all the visible files in a directory. If you’re familiar<br />

with D<strong>OS</strong>, it would be the replacement for dir. By default, the ls command looks something like<br />

this:<br />

<strong>Leopard</strong>:~ scott$ ls<br />

Desktop Library Music Public<br />

Documents Movies Pictures Sites<br />

CHAPTER 18 INTRODUCING DARWIN AND THE SHELL 293

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!