Navigating in Unix

If you can’t see any icons for your files and folders, how are you supposed to work with them?

You have no choice but to ask Unix to tell you what folder you’re looking at (using the pwd command), what’s in it (using the ls command), and what folder you want to switch to (using the cd command), as described in the following pages.

pwd (print working directory, or “Where am I?”)

Here’s one of the most basic navigation commands: pwd, which stands for print working directory. The pwd command doesn’t actually print anything on your printer; instead, the pwd command types out, on the screen, the path Unix thinks you’re in (the working directory).

Try typing pwd and pressing Enter. On the next line, Terminal may show you something like this:

/Users/chris/Movies

Terminal is revealing the working directory’s path—a list of folders-in-folders, separated by slashes, that specifies a folder’s location on your hard drive. /Users/chris/Movies pinpoints the Movies folder in Chris’s Home folder (which, like all Home folders, is in the Users directory).

Note

Capitalization counts in Unix. Command names are almost always all lowercase (like cal and pwd). But when you type the names of folders, be sure to capitalize correctly.

Get Mac OS X: The Missing Manual, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.