Datasheet

684
Working with Files
Paths
Before you dive into UNIX commands, you should first know a few facts . . .
nasty things, facts, but you can’t earn your pair of techno-wizard suspenders
without ’em. For starters, as a Mac user, you might not be familiar with how
paths work in UNIX. A path is simply a textual representation of a folder or
file. The simplest path is your Home directory, which is denoted by a tilde
character (~) — the tilde character acts as the equivalent of /Users/<your
short account name> (in my case, /Users/markchambers). Any folder
within the Home directory is represented by the folder’s name preceded by
a forward slash (/). For example, a document entitled myDoc that resides in
the current user’s Documents folder would have a path like this:
~/Documents/myDoc
Similarly, a folder named myFolder that resides in the current user’s
Documents folder would have a path like this:
~/Documents/myFolder/
As you’ve probably surmised, a folder and a directory are two different
names for the same thing. Folder is the name with which most Mac users are
familiar, and directory is a term that UNIX power users prefer. I use the terms
interchangeably throughout the remainder of the chapter.
Because Mac OS X is a multiuser environment, you might sometimes want
to work with folders or files somewhere other than in your Home folder.
Starting from your Home folder, enter the following command:
cd ..
This moves you to the folder right above your Home folder, which happens to
be the Users folder. Using another quick ls command will show you all users
who are permitted to use the machine. (By the way, Shared isn’t a user —
it’s a folder with privileges set so that any user can access its contents.)
Enter cd .. once again, and you find yourself at the root of your main hard
drive. The root directory is what you see in the Finder when you double-click
your hard drive icon on the Desktop. A user’s Home directory is represented
by a tilde character (~), and the root of the hard drive is denoted by a for-
ward slash (/), as displayed by the prompt:
WHITEDRAGON:/ markchambers$
It’s easy to return to your Home directory by following this sequence:
WHITEDRAGON:/ markchambers$ cd Users
WHITEDRAGON:/Users markchambers$ cd markchambers
WHITEDRAGON:~ markchambers$
55_9781118022061-bk08ch01.indd 68455_9781118022061-bk08ch01.indd 684 8/10/11 9:39 AM8/10/11 9:39 AM