Datasheet

678
Uncovering the Terminal
As you might guess, this text details the last time that you logged into the
Terminal. The last line, however, is the more important one. It’s called
the prompt.
The prompt serves some important functions. First, it lists the current direc-
tory, which is listed as ~ in the above example. A tilde character (~) denotes
a user’s Home directory. By default, you’re always in your Home folder each
time you begin a new session on the Terminal. After the current directory,
the Terminal displays the name of the current user, which is markchambers
in this example.
The final character of the prompt is a $. Consider this your cue because
immediately after this character is where you enter any command that you
wish to execute. Go ahead; don’t be shy. Try out your first command by
typing uptime in the Terminal application. (It’s a good idea to type UNIX
commands in lowercase.) Your text appears at the location of the cursor,
denoted by a small square. If you make a mistake while entering the com-
mand, press the Delete key to back up and then type the characters again. (If
the typing error is stuck deep in a longer command, press the left- or right-
arrow key to move the cursor immediately after the incorrect character and
press Delete to back up; then type the correct characters.) After you type
the command, press Return to execute it.
WHITEDRAGON:~ markchambers$ uptime
6:24PM up 2:42, 4 users, load averages: 2.44, 2.38, 1.90
WHITEDRAGON:~ markchambers$
If all goes well, you should see a listing of how long your Mac has been run-
ning since the last reboot or login. In the example listing, the computer
has been running for 2 hours and 42 minutes (2:42 in line 2). Simple, eh?
Immediately following the listing of the uptime command, the Terminal
displays another prompt for you to enter more commands. I examine many
more commands later in this chapter.
Prefer a different appearance for the Terminal window? Click the Terminal
menu and choose Preferences; then click the Settings toolbar button to
choose the color combinations for the Terminal window background
and text.
A few commands to get started
Using the command line is simply a matter of entering simple instructions —
or commands — into the Terminal application and pressing Return to
execute them. It’s easy to use the command line to navigate through the
various folders on your hard drive. You’ll become accustomed to using two
vital commands: ls and cd. The ls command is shorthand for list, and it
does just that: It lists the contents of the current directory. Enter ls at your
prompt, and you should see a listing of your Home folder.
55_9781118022061-bk08ch01.indd 67855_9781118022061-bk08ch01.indd 678 8/10/11 9:39 AM8/10/11 9:39 AM