Seeing the Whole File System

Seeing the Whole File System

An important difference between the Unix and Aqua (and Mac OS 9) approaches to files and directories is the way the user sees disks and the locations of files.

Aqua displays files in folders, which are in turn located on volumes . (There is one or more volume per disk. Volumes show up in the Finder looking like disks.) Each volume has its own hierarchy of files and folders.

In Unix there is only one hierarchy of directories and files. If you have more than one volume on your system, then each volume is a part of one centralized hierarchy, rather than appearing as separate volumes on the desktop, as in Mac OS 9. The beginning of the hierarchy is the root directory. The root directory is always on the volume that you booted from it contains the kernel of the operating system. Figure 5.1 shows the hierarchy of your entire file system contained on three disks. (See the sidebar "Disks, Partitions, Volumes, and Removable Devices" for even more details.)

Figure 5.1. There is only one hierarchy of files on your system no matter how many disks and volumes you have. Unix uses a file in the /dev directory to represent each volume, so /dev/disk0s9 represents "disk zero, slice 9."

To see the contents of the root directory:

  • ls /

    As discussed in Chapter 2, the ls command (for list ) shows the names of files and directories. It can be used with any number of arguments. If an argument is the name of a directory, then the contents of that directory are shown; Figure 5.2 shows the contents of the root directory.

    Figure 5.2. Typing ls / shows the contents of the root directory. Your output depends on your machine's configuration.
     localhost:~ vanilla$  ls /  Applications          Library        automount        mach             tmp Desktop DB            Network        bin              mach.sym         usr Desktop DF            System         cores            mach_kernel      var Developer             Users          dev              private Installers            Volumes        etc              sbin localhost:~ vanilla$ 

Your first thought may be, "Where did my disk(s) go?" You may have noticed that the disks you see in the Finder didn't show up in that listing. The answer is that disks and/or volumes are displayed in a normal Unix listing of the root directory. (In Unix, virtually everything is a file of some kind.) Unix uses a special file in the /dev directory to represent each disk and volume on the system. The /dev (for devices ) directory contains files that represent various physical and virtual devices, so /dev/stdin represents the STDIN we talked about in Chapter 2 and /dev/disk0 represents the first physical disk. Then /dev/disk1 would be a second disk, and /dev/disk0s2 would be "disk 0, slice 2" (a slice is also known as a partition , or volume ).

Disks, Partitions, Volumes, and Removable Devices

On Unix systems, there is always a single hierarchy containing all files and folders available to the operating system, regardless of how many physical disks or other devices are attached.

Each storage device (disk, CD, and so on) shows up in the master hierarchy (the file system) as a directory.

Physical disks may be divided ( partitioned ) into two or more volumes (also called partitions and filesystems ).

On a Unix system the boot volume is always the root of the whole file system. (Note that the file system may have multiple filesystemsthat is, volumes.)

In the Finder and other Aqua applications, each volume will appear as if it were a separate disk.

In Darwinthat is, at the command lineeach volume is said to be mounted on a directory. (So the boot volume is mounted on the / directory.) In Figure 5.1, the second internal disk is mounted on the /Users directory, and we say that /Users is the mount point for the second disk (which is also represented by a special file, /dev/disk1s9 ; all "devices" are represented by special files in the /dev directory).

In Darwin/Mac OS X, removable devices are mounted on directories automatically created inside the /Volumes directory, so in Figure 5.1, the Audio CD is mounted on the /Volumes/Audio CD directory.

The df command will show a list of filesystems and mount points. (Remember that filesystem and volume and partition all mean the same thing.) See man df for more. Figure 11.40 in Chapter 11 shows an example of using the df command.

Compare with Aqua

Normally the Aqua interface hides much of the contents of the root directory when it is viewed in the Finder. This is probably because Apple doesn't consider the items it has hidden to be useful to an Aqua-only user. You can change this on a per-user basis by using the command-line utility defaults to turn on an option called AppleShowAllFiles . Here is the command line to do this:

 defaults write Apple  ShowAllFiles ON 

See man defaults and also "Configuring Mac OS X Defaults from the Command Line" in Chapter 7, "Configuring Your Environment with Unix."

The Aqua interface tries to keep you away from the more hard- core Unix files and folders.

If you choose Go to Folder from the Go menu in the Finder and then type in a / (slash), you are shown a list of the disks and partitions on your system, along with the Network icon.

You can use the Go to Folder dialog to navigate into some of the hidden directories; for example, if you type in /usr , you are shown the contents of the /usr directory as shown in Figure 5.3 . You just can't see the root directory itself.

Figure 5.3. Result of entering /usr in the Go to Folder dialog from the Finder's Go menu.

Some Aqua applications let you navigate to the root directory by typing in the "Go to" field of the Open dialog. Even then, however, the view you get does not show every file and directory in the root directory. If you know the full path of a hidden file or directory, you may navigate to it by entering the full path . (Some Aqua applications, notably the BBEdit text editor, have an Open Hidden choice under the File menu.)

Unix for Mac OS X 10. 4 Tiger. Visual QuickPro Guide
Unix for Mac OS X 10.4 Tiger: Visual QuickPro Guide (2nd Edition)
ISBN: 0321246683
EAN: 2147483647
Year: 2004
Pages: 161
Authors: Matisse Enzer

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: