11.2. Unix Basics

The Unix philosophy, which Mac OS X shares at its lower levels, can be summarized by the old adage that many hands make light work. Unix systems are full of commands—small programs that are highly specialized. Each command does one thing, and does it well. Even though the foundations are simple, you can achieve powerful tasks by combining Unix commands. This section covers basic aspects of Unix, some of the most important Unix commands, and how you can combine them to achieve your objectives.

11.2.1. Paths

Much of the time spent interacting with an operating system involves working with files and directories (that is, folders). You have to be able to locate files, view or edit them, move them, remove them, and so forth. But all these actions require that you be able to stipulate to the operating system which file or directory a particular action involves. In Finder, you can select a file and drag it to the Trash if you want to remove it. On the command line, there are no file icons; so you need to give a path to any file or directory you want to use in a command.

Unix paths can take one of two forms: absolute paths and relative paths. Absolute paths are spelled out in full with respect to the root directory. An absolute path begins with a forward slash, as in the following:

cd /Users/terry/Desktop

This line uses the cd command, which changes the current working directory of the shell. The current directory is set to the Desktop folder of user terry. The path ...

Get Beginning Mac OS® X Programming 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.