Navigating the Filesystem
When you open a Finder window and work with its icons, that window represents a particular folder. Likewise, when you open a Terminal window, its shell is working “in” some directory. More technically, your shell has a current working directory (analogous to your open Finder window). When you run commands in that shell, they operate relative to the current working directory. Figure 1-7 illustrates this concept. If your shell is “in” the directory /Users/smith/stuff, and you run a command that refers to a file receipt.pdf, then the file is really /Users/smith/stuff/receipt.pdf.

If a path begins with a slash, such as /one/two/three, it’s called an absolute path. If not, it’s a relative path, because it’s relative to a shell’s current location in the filesystem. For instance, a relative path a/b/c, when referenced from the current directory /one/two/three, implies the absolute path /one/two/three/a/b/c. In general, if you refer to a relative file path in a shell, the path is relative to your current working directory.
Two special relative paths are . (a single period) and .. (two periods in a row). A single period refers to your current directory, and two periods means your parent directory, one level above. So if your current directory is /one/two/three ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access