The File SystemWhere Did Everything Go?
Mac OS X radically changes the way that Mac users interact with their files by imposing structure on a system that previously allowed a user to delete just about every file and folder on his hard drive before complaining. For those of you who have been using the Mac OS for 15 years, this change might come as an unwelcome surprise. Interestingly, Windows 2000/XP and Linux users are likely to be more accustomed to these restrictions already.
The goal of the OS X project is to provide system stability and ease of use to as wide a range of users as possible. To do this, Apple created sets of directories that must exist on each Mac OS X installation. This produces consistency across different copies of the operating system, and makes it simple for application installers to choose the appropriate place for storing files. Users cannot modify the system-level directories or move them out of their default location. Anyone with experience using Mac OS 8 or 9 will, at one point in time, have installed a piece of software only to ask "Where in the world did that file just go?" Under Mac OS X, you'll know.
The "Computer Level" of the File System Hierarchy
Like the My Computer icon in Windows, Mac OS X provides a topmost view of the storage devices accessible to the machine. You can still see your drives mounted on the desktop, but you can also access them by looking at the Computer view of your system. Figure 3.2 shows a Finder window that is viewing the top level of the system.
Figure 3.2 Mac OS X provides access to your drives and network within a Finder window, as well as on the desktop.
In Figure 3.2, there are three icons visible: Network, Mac OS X, and Mac OS 9.x. Within these three locations are all the files that are located on my system. Any additional FireWire or USB drives that are plugged into the system will appear in this location, as well as being mounted directly on the desktop.
The purpose of the hard drive icons should be obvious: to navigate the file system just as you would in Mac OS 8/9 or Windows. The Network icon, however, might require a bit of explanation.
The Network icon will be used on clustered Mac OS X installations to provide a central point of access to multiple servers, shared applications, and other network resources. In its current incarnation, it serves little purpose but to confuse the user. Mounted AppleShare volumes cannot be found within the Network directory, nor can you browse the available servers from this location. Later in the book you'll learn about a Windows-compatible file sharing tool called Sharity, which allows browsing of Windows shares within Network, but until this feature is better fleshed out by Apple, its practicality for the home user is debatable.
Linux and Unix users might recognize the Computer level of the file system as being the same as the root level of a Unix file system. In reality, the root level starts with the Mac OS X boot diskall other volumes use mount points below that volume (under the /Volumes directory). The Computer view of the file system is an artificial construct created by Apple to provide a top-level view of all resources available on the computersimilar to My Computer on Windows.
The Top-Level Mac OS X File System
When you open your Mac OS X boot drive, you should see a collection of permanent folders, similar to those in Figure 3.3. These directories contain all the preinstalled applications, utilities, and configuration files for your system. This will be your starting point of accessing most of the functions of your system.
Figure 3.3 The Mac OS X top-level file system contains several permanent folders.
As a normal Mac OS X user, you cannot modify these folders by moving, renaming, or deleting them. In addition, you cannot create new folders at this level of the drive. Don't worry too much about this. If you really want to create a new folder, there are ways to do it by using the root user account. You can also create folders and files within these locations if necessary.
The Applications folder contains all the preinstalled Mac OS X applications, such as TextEdit, Mail, QuickTime Player, and many others. Any application located within this folder will be accessible to any user on the system. If you're installing an application that should be accessed by only a single person, it might make more sense to store the application within the user's home directory (home directories will be covered shortly).
Perhaps more interesting than the applications in the Applications folder is the Utilities folder also located within. The Utilities folder contains tools necessary to set up your printers, calibrate your display, and other important tasks.
The Utilities folder can be modified by the default Mac OS X user. You can move, rename, or delete the folder if you'd like, but problems might arise. For reasons beyond explanation, Apple hardcoded the location of the Print Center into the system. When you attempt to print from Mac OS X, if Print Center cannot be located in the Utilities folder, it will not be launched. If you must rename your Utilities folder, you can manually start Print Center to complete any pending print jobs. This problem is fully described in Apple's TIL: http://til.info.apple.com/techinfo.nsf/artnum/n106265.
This problem might affect other applications automatically launched from the Utilities folder as well.
The Library is a new addition to the Mac OS file system, and demonstrates the modular construction of the OS X system. Although is does not have a strict definition, you can think of the Library as a storage location for system-wide application preferences, application libraries, and information that should be accessible to any user. Figure 3.4 shows the contents of the Library folder on a clean Mac OS X installation.
Figure 3.4 The Library provides applications with a system-wide information storage area.
Some of these folders are used by applications to data such as preferences, whereas others hold printer drivers or other system additions made by the user. The default Library folders you'll find upon installation include:
Application SupportContains files that are used by, but are not necessarily part of, an application. For example, the StuffIt engine is used globally by several compression utilities. Rather than having multiple copies of the engine for each program, a single copy of the engine is located in the Application Support folder.
AudioContains application or user-added sounds and plug-ins for the Mac OS X audio system.
CachesStores cached network information.
ColorSyncStores ColorSync output device profiles as well as scripts to work with ColorSync information. Mac OS X includes a large number of AppleScripts that can be used immediately, including the ability to mimic the color settings of a typical PC monitor.
Desktop PicturesAlthough desktop pictures can be loaded from any picture file, the Desktop Pictures directory provides a central storage area for all users to access picture files.
DocumentationIf a third-party application installs documentation beyond traditional program helps, it should automatically be added to this folder.
FontsUser-installed fonts can be added to the Fonts folder.
Image CaptureMac OS X includes an extensible utility for retrieving images from digital cameras and other forms of digital media. This folder contains scripts that can automatically crop images or create Web page galleries.
Internet Plug-InsRather than multiple browsers needing multiple copies of the same plug-in, or multiple users each needing a copy, the Internet Plug-Ins directory stores a single copy, accessible by any program that needs them.
JavaJava is an integral portion of Mac OS X. If there are Java class libraries that should be available to anyone using the system, they can be stored in the Java folder.
LogsLog files generated by user-level services, such as file sharing are stored here.
Modem ScriptsThe scripts necessary to initialize all the Mac OS X-supported modems are stored here. These scripts are simple text files that can easily be modified to work with unlisted modems.
PerlPerl module information is stored within the Perl directory. Users should never need to manually update the contents of this folder.
PreferencesSystem-wide preference files. Because Mac OS X supports multiple users, each user should have his own preference file (located in his home directory). This folder contains preferences that are global; that is, across all users.
PrintersDrivers and utility software to manage third-party printers. Printer page description files can also be found here.
ReceiptsWhen an application uses the Apple installer to copy files to the system, it leaves behind a .pkg (package) file that contains a complete list of all the files that were installed on the system and where they are located. This list can be read by opening the Installer application (double-click the .pkg file) and choosing Show Files from the Edit menu.
Screen SaversMac OS X includes its own screen saver engine. Within two weeks of the OS X release, more than 30 new screensaver modules were written. To add a new screen saver, just download the module and place it in this folder. It will be accessible by all user accounts on the system.
ScriptsA number of useful AppleScripts are stored in the Scripts folder. Everything from Finder to e-mail automation is included.
StartupItemsIf a StartupItems folder doesn't exist on your system, you can create one. Any properly configured services will be executed from this location automatically. Note: This is not to be used in the same manner as the Startup folder on Mac OS 9. Applications placed here will not start when the computer is booted.
User PicturesIn Mac OS X 10.1, Apple returned to a graphical login screen, similar to the multiuser interface in OS 9.x. To add custom pictures for all users to choose from, place them here.
WebServerCGIs (executable programs designed to work with a Web browser), and HTML documents are stored here. These can be used to build an industrial-strength Web server.
Keep in mind that if you plan to run a system with multiple user accounts, these folders affect all users on the system. For example, if you purchase a screen saver module for yourself, putting it in the Screen Savers folder gives access to all users. To restrict access to a single account, you'll have to install directly into your home directory, discussed shortly.
If your computer is being used as a personal workstation, it's best to leave the Mac OS X installation as "untainted" as possible. Almost all the items contained in the Library folder can also exist within your home directory. As you'll soon learn, your home directory is yours to configure however you see fit. Keeping system-wide configuration as simple as possible helps to make backing up and restoring a system very straightforward.
Next up on the list is the Mac OS X System folder. By default, the System folder contains one other folder, called Library. This is a more specific version of the same Library folder that contains the Fonts folder and other resources. Within the System's Library folder are contained the components that make up the core of the Mac OS X experience. Even though it is possible to perform some interesting hacks to the operating system, these files and folders should not be changed unless you are aware that any modifications you make could result in your computer becoming unbootable.
The Users directory is probably the most interesting and important addition to the Macintosh file system. Although it is present in Mac OS 9, the multiuser capability pales in comparison to what is available under Mac OS X.
Mac OS X is based on an underlying Unix operating system. Within Unix, each file and folder belongs to a specific user and group. The owner of a file is exactly what it sounds likethe person to whom that file belongs. If you create a file, you own it. As the owner, you have the right to decide whether you want other people to be able to view it or edit it. A file or directory's group is similar to the owner, but whereas an owner is a single person, a group can consist of many different people.
For example, assume that you (Joe) are working with team members on an annual budget report. The members of the team who should be able to read the file are Betty, Bob, and Sue. Because there can be only one owner, Betty, Bob, and Sue can be given access to the file by assigning them to a group, such as ReportReaders, and then allowing ReportReaders the ability to read the files.
In Mac OS X, there is a default group named Staff that is shared between all accounts on the system. This makes it very easy to share a file between all the accounts on the system. If you'd like tighter control for limiting access to smaller groups of people, you can do that as wellwith a little bit of work. Chapter 24, "User Management," discusses the use of user and group permissions from the BSD command line and using Mac OS X's graphical tools.
There is another possibility for allowing multiple people to have access to a single file: granting access to the "world." In the event that everyone should be able to read a file, you can also grant access to anyone. This is the typical mode of operation for the traditional Mac operating systemeveryone has access to everything.
These three attributes for allowing access to a file (owner, group, and world) are controlled via three sets of permissions:
Owner Permissions Also called user permissions, these control whether a file's owner can read, write, or execute a file or application.
Group PermissionsGroup permissions control read, write, and execute access for members of the group that is assigned to the file. If only the owner should have access to the file, the group permissions can be set to "none."
World PermissionsPermissions that affect everyone else; that is, those not in the file's group and not the owner. If a file has world read/write/execute access turned on, anyone with access to the system will be able to edit or delete the file.
The owner of a file can always change the permissions that are associated with that fileeven if they've turned off read or write access for themselves. Why would a file's owner want to shut off the ability to read or write his or her own file? Have you ever accidentally deleted a file on your system? If so, you already know why.
Of the three permissions that can be set for the owner, group, or world, the read and write attributes should be obvious. They control the capability to read from files and write to them. The execute attribute controls whether a file should be capable of being launched by someone on the system. Some applications should be accessible by only certain users, and this attribute provides a means of selectively enabling a program to execute in the same way you can enable reading or writing.
As mentioned earlier, Mac OS X does not allow normal user accounts the capability to modify the folders at the top level of the hard drive. This is because those folders are owned by an account called the root or super-user account. Although it's tempting to use the root account to gain complete control over the system, it's also highly dangerous. For this very reason, Apple has disabled the root account in Mac OS X. Enabling the account will be covered, but isn't recommended unless you're comfortable making changes that could affect your system's ability to boot.
The Home Directory
So, the system allows users to own their own files and provides a means of controlling other users' access to these fileswhat does that have to do with the Users directory that we're discussing? The Users directory contains the home directories of all of the users on the machine. A user's home directory can be considered that user's workplace. It is hers, and hers alone. Files and folders that are stored within a user's home directory are protected from other users.
If you've been a Mac user for a long time, you should start to think of your home directory as the place where you can make all your modifications to the folder arrangement and structure. Your home directory is the start of your personal area on Mac OS X. You can add documents, applications, fonts, screen saversjust about anything you can think of. Best of all, no one can mess with your configuration; conversely, you can't mess with anyone else's!
Within the Users directory are directories for each of the users on the systemthese are the home directories themselves. Your directory will be named using the short name that you chose when you created your Mac OS X user account. Apple has created several default folders in your home directory, as shown in Figure 3.5.
Figure 3.5 The home directory is filled with several default folders.
DesktopThe Desktop folder is much like what it always has been: a folder that contains everything that shows up on your desktop. In older versions of the Mac OS, this folder is invisible unless you are connecting to a remote Macintosh AppleShare server, in which case you could see the remote machine's Desktop folder. In Mac OS X, the Desktop folder is always visible in your home directory.
DocumentsA generic store-all location for any documents that you create. This is just a recommended storage location to help organize your files.
LibraryThe Library folder is the same as the top-level Library folder and the Library folder within the System folder. Within the directories in this directory, you can store fonts, screen savers, and many other extensions to the operating system.
MoviesThis is another generic storage location where you can keep your iMovies and other media.
MusicA generic location for storing your MP3s and various audio files.
PicturesA generic location for storing pictures. As with the other storage location, these are just suggestions for you to use. Some software might default to the appropriate location for the file type it is creating, but there's nothing stopping you from storing your files elsewhere.
PublicIf you plan to share your files over the network, you can do so by placing them in the Public folder and activating file sharing within the Sharing System Preferences panel. This will be discussed in Chapter 9, "Network Setup." Inside the Public folder is another folder called Drop Box. Other users can place items inside your drop box, but they cannot open the Drop Box folder itself. A small down arrow is located at the lower-right corner of the Drop Box icon to identify it visually.
SitesThe Sites folder contains your personal Web site. Unlike Mac OS 8/9, which allows a personal site to be located anywhere, Mac OS X uses the Sites folder. This small sacrifice in flexibility is easily overlooked when you consider that each user's personal Web site can be served simultaneously.
The top-level Library folder, the System folder's Library folder, and the Library folder in the user's home directory are all similar. Each can hold components that are used by other parts of the operating system.
The operating system evaluates these in the order of System Library, top-level Library, and then the Library in each user's folder. To keep files as consolidated as possible, it's best to store components in your home Library folder. If there are items that should be accessible to all of the operating system's users, place these within the top-level Library.
You should never need to change the contents of the System folder.
Even though Apple has been kind enough to include specific folders for different file types, feel free to do anything you'd like with your home directory. The only folders that should not be modified are the Desktop and Library folders. These are critical to system operation and must be maintained.
By default, a user can access only the Public and Sites folders within another user's home directory. Other folders appear with a red minus symbol in the lower-right corner. This indicates that no access is available to that location.