Mac OS X has a hierarchical, or treelike, file structure that makes it possible to organize files so that you can find them quickly and easily. The file structure contains directory files and ordinary files. Directories contain other files, including other directories; ordinary files generally contain text, programs, or images. The ancestor of all files is the root directory named /.
Most OS X filesystems support 255-character filenames. Nonetheless, it is a good idea to keep filenames simple and intuitive. Filename extensions can help make filenames more meaningful.
When you are logged in, you are always associated with a working directory. Your home directory is your working directory from the time you first log in until you use cd to change directories.
An absolute pathname starts with the root directory and contains all the filenames that trace a path to a given file. Such a pathname starts with a slash, representing the root directory, and contains additional slashes between the other filenames in the path.
A relative pathname is similar to an absolute pathname but starts the path tracing from the working directory. A simple filename is the last element of a pathname and is a form of a relative pathname.
Among the attributes associated with each file are access permissions. They determine who can access the file and how the file may be accessed. Three groups of users can potentially access the file: the owner, members of a group, and all other users. An ordinary file can be accessed in three ways: read, write, and execute. The ls utility with the l option displays these permissions. For directories, execute access is redefined to mean that the directory can be searched.
The owner of a file or Superuser can use the chmod utility to change the access permissions of a file. This utility specifies read, write, and execute permissions for the file's owner, the group, and all other users on the system.
Mac OS X files have extended attributes, which include file attributes used by the Finder, Access Control Lists, and resource forks. Not all utilities recognize extended attributes.
An ordinary file stores user data, such as textual information, programs, or an image. A directory is a standard-format disk file that stores information, including names, about ordinary files and other directory files. An inode is a data structure, stored on disk, that defines a file's existence and is identified by an inode number. A directory relates each of the filenames it stores to a specific inode.
A link is a pointer to a file. You can have several links to a single file so that you can share the file with other users or have the file appear in more than one directory. Because only one copy of a file with multiple links exists, changing the file through any one link causes the changes to appear in all the links. Hard links cannot link directories or span filesystems, whereas symbolic links can.
Table 4-4 summarizes the utilities introduced in this chapter.