MacBook For Dummies
Book image
Explore Book Buy On Amazon

The best way to find out how to use the UNIX command line is to jump right in. Mac OS X comes stocked with an application named Terminal. The Terminal application is where you enter commands in the command line. It’s located in the Utilities folder within the Applications folder on your hard drive — choose Applications→Utilities (from the keyboard, press Shift+Command+U).

Double-click the icon to launch Terminal.

image0.jpg

What’s a command line prompt?

Upon launch of the Terminal application, you’ll immediately notice some text in the window that appears on-screen:

Last login: Sun Jun 23 17:51:14 on console
 WHITEDRAGON:~ markchambers$

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 directory, which is listed as ~ in the preceding 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 command, press the Delete key to back up and then type the characters again. 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 running 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). Immediately following the listing of the uptime command, the Terminal displays another prompt for you to enter more commands.

Use the skills you already have

Just because the Terminal is text based doesn’t mean that it doesn’t act like a good Macintosh citizen. All the usual Mac features that you know and love are there for you to use. Copy and Paste functions work as you might expect, but only at the prompt position.

Drag-and-drop is also at your disposal. After you play around with the Terminal for a while, you’ll find yourself bored to tears typing the long paths that represent the files on your hard drive. To automatically enter the path of a file or folder to a command, simply drag it to the active Terminal window. The file’s full path instantly appears at the location of your cursor. (Thanks, Apple!)

image1.jpg

You can even use the mouse while entering commands in the Terminal. Click and drag your mouse over text to select it. From there, you can copy to the Clipboard as you might expect with any other application.

About This Article

This article can be found in the category: