If you've ever decided to take a curious trip around your hard drive, you've surely discovered that Mac OS X includes tens of thousands of files, organized in hundreds and thousands of folders and sub-folders. If you're a former user of Mac OS 9 or earlier, the sheer number of files that are present is enough to make you wonder if upgrading to OS X was such a great move. However, the truth is that despite the large number of files, OS X and its applications are organized in a fairly logical manner. Understanding the basics of application and system software organization will help you better understand installations (and installation troubleshooting).
I spent a good amount of time talking about OS X's file and folder organization in Chapter 1, but I'm going to briefly revisit this organization as it relates to software installation.
Mac OS X The bulk of files and folders in most computers running Mac OS X is made up by the operating system itself. Because of the sheer number of files installed by Mac OS X, explaining the location and purpose of each and every file would take more space than this entire book! Thus, for the sake of this discussion, I'm going to generalize a bit. Core OS-related files are installed inside the directory /System at the root level of your hard drive. Support files are located in /Library, as well as in a few invisible folders at the root level, such as /usr and /sbin. (I'll talk more about invisible files in Chapter 5, "Finagle Files and Foil Finder Frustration.") I've already mentioned a few such files in the preceding chapters, and you'll work with a number of others before the book is through.
Applications I discussed Mac OS X's "parallel" folder structure in Chapter 1; application location is another example of parallel folders. Applications are generally located in /Applications (for all users) or in ~/Applications (for individual users). Although applications can technically be installed anywhere, there are good reasons to limit them to these folders—see "Moving Installed Applications" later in the chapter for more information.
As discussed in Chapter 1, the ~/Applications folder (within each user folder) isn't created automatically, so each user will need to create it within their own folder if they want to take advantage of it.
Many applications also require support files. These files are often located within the application itself (see "Packages," later in this chapter); however, this is not always the case. Inside /Library (for all users) and ~/Library (for individual users), you'll most likely find a folder called Application Support, inside which you'll find folders containing support files for various applications. Applications may also store fonts, contextual menus, help files, and other necessary files inside specialized folders in the /Library directories. In addition, as mentioned earlier in the book, applications save their preferences inside /Library/Preferences and ~/Library/Preferences (again, depending on whether the preferences apply to all users or if each user has their own preferences). Finally, if an application requires a low-level startup item that needs to be active at startup (such as the backup scheduler used by Dantz's Retrospect backup application), it will most likely be located in /System/Library/Startup Items.
If you're running Mac OS X on a computer that previously ran Mac OS 9 or earlier, you may also have a folder at the root level of your hard drive called Applications (Mac OS 9). This is where applications that were previously installed under Mac OS 9 are stored. You may be able to run many of these applications using the Classic Environment (see Chapter 8, "Clobbering Classic").
Utilities Utilities are actually just applications, and there really is no official way to differentiate between an application that is a utility and one that isn't—I generally think of utilities as applications that do something to your computer (fix it, alter its functionality, etc.), or help you monitor your computer (e.g., Network Utility lets you monitor network traffic). Mac OS X has a special folder inside /Applications called Utilities. This folder contains all of the utilities that are installed by OS X (e.g., Terminal, Disk Copy, Network Utility), as well as any utilities installed there by third-party installers or placed there by users.
System add-ons You can alter or enhance the way Mac OS X works in many ways. We've discussed a few (screen savers and preferences panes) already in the book. However, where these add-ons reside depends on the type of add-on. I go into more detail about these locations in "Adding Add-ons," later in this chapter.
Unix software In addition to software written for Mac OS X, many command-line applications are pre-installed by Mac OS X. You can also install many other Unix applications yourself. I'll talk much more about installing Unix software in Chapter 15, "Utilizing Unix," but for now I'll just briefly mention that a good number of command-line Unix applications are located in the invisible /bin, /sbin, and /usr directories. Many of these applications are used regularly by Mac OS X itself, and many others are accessible to you via Terminal.
If you previously used a Mac running Mac OS 9 or earlier, you'll remember that when you installed an application, you generally also installed various other files needed by that application. Sometimes these files were conveniently located in the same folder as the application itself; however, they were often scattered across your hard drive—some in the Extensions folder, some in the Control Panels folder, some in various other locations depending on the application.
This made for a very messy hard drive, and for potential problems. An application could stop working as a result of seemingly innocuous actions such as:
Moving the application from its original location
Moving an application around within its own folder
Accidentally moving or throwing away an essential support file (which could be easy to do because an application's folder was often littered with support files)
Accidentally moving or disabling support files such as System extensions
Mac OS X makes some impressive strides towards eliminating this type of situation by using what are called packages (technically called bundles, but since Apple has taken to calling them packages, I'm going to do so as well). A package is actually a folder of files that acts like a single file. For example, an application package is a folder that contains an application and its support files; however, the package looks and behaves like an application—double-clicking it doesn't open the folder; rather it launches the application inside. An installer package is a folder that contains all the files and/or resources needed for a particular software installation; double-clicking on this kind of package launches Mac OS X's Installer utility.
File packages have a number of advantages. Most importantly, as I'll discuss shortly, is that they make installing new applications much easier. But in addition, they also make it less likely that a user will accidentally move or delete files needed by applications, and they make it easier to move applications and other types of packages around (including deleting them when you want to).
To see a package in action, navigate to /Applications, and locate the Mail application. If you hold the control key and click on Mail (or right-click if you have a multi-button mouse), you'll be presented with a contextual menu. Select Show Package Contents from the menu. You'll be presented with a new Finder window with a folder called Contents. Inside that folder are the actual contents of the Mail package (Figure 4.1). If you dig into the Resources folder, you'll even see the various TIFF graphic files used by Mail for buttons and toolbars.
There are actually several types of package files. If you have chosen to view files extensions in the Finder (via Finder preferences), you'll recognize some packages by their file extension: installer packages end in .pkg; application packages end in .app. Files that end in .bundle, .framework, and .menu are a few other examples. All of these are examples of bundles of files that appear in the Finder as a single file.
It's possible to create your own packages, but you really don't want to do it unless you're familiar with all of the types of files that need to be included; if you're not, you'll be left with a package that doesn't do anything. For more information on packages, check out http://developer.apple.com/techpubs/macosx/Essentials/SystemOverview/AppPackaging/.
If you remove the file extension (.app, .pkg,.bundle, etc.) from the name of a package or bundle, it will no longer function properly; likewise, if you add a package extension to the name of a normal folder or file, it will become a package, but will not function like one. In fact, you may not be able to easily get your folder back. So be careful with file extensions. (See Chapter 5 for more information on file extensions.)
If you're really interested in the contents of a particular installer package (or even if you just want to see such a list once, so that you never have to wonder again), a neat little AppleScript called QuickBom (http://homepage.mac.com/bhines/applescripts.html) will show you. Drop a .pkg file onto the QuickBom icon, and QuickBom will create a new TextEdit document with a list of every file inside the package, organized by file path. (QuickBom is actually an AppleScript interface for the Terminal command lsbom, but automates the process.)
Throughout the rest of this chapter I'll be talking about how to install (and uninstall) software, including applications, system software, and system add-ons. However, before I do so, I want to quickly talk about moving files, including applications.
Many users (including myself) like to keep their hard drive neat and organized. For example, under OS 9 I liked to create a folder called Internet inside my Applications folder and put any Internet-related applications inside. However, this isn't such a good idea under Mac OS X, which can be quite strict when it comes to file location. As you might expect, system-related files only work properly when they are installed in the correct location. However, because of permissions issues and even software updater issues, many other files must also be in particular locations.
For example, I mentioned earlier in this chapter that applications should be located in /Applications or ~/Applications. There are a few reasons for this organization. First, the permissions on these folders are set to provide the appropriate users with access to applications. If an application was installed in /System/Library, for example, only the root user would be able to use it; by installing applications inside the Applications folders, all users (or particular users, in the case of ~/Applications) can use them. Second, some applications are written so that they must be located in one of the Applications folders; if they are not, they won't function properly. Third, many utilities that provide quick access to applications only do so for applications located inside these folders. (We'll discuss some of these utilities later in the book.) Fourth, Mac OS X maintains a database of installed applications, and updates it automatically whenever it detects a newly installed application; however, it only does this for applications that reside in the official Applications folders. This database is used, for example, whenever you double-click a file to open it. Finally, in my opinion, it simply makes your computer more organized and easier to use if applications are conveniently located in the Applications folders.
In addition to these reasons, in the case of Apple's own applications (those installed with Mac OS X), there is an even more persuasive argument for keeping them where they were originally installed: the Mac OS X software updaters will sometimes only update software that is located in its original location. For example, if you move the Mail application out of the /Applications directory, or even just inside a sub-folder within /Applications, a Mac OS updater (an update to Mac OS X, or an application-specific updater), may not update the Mail application. Sometimes the updater will look for Mail in its original location, and when it doesn't find it there, it will either do nothing, or will install a new package of files where Mail should be. This package will look like a new Mail application package, but will only contain the files that were supposed to be updated within the Mail package. In other words, it will be incomplete and will not function. Apple claims that as of OS X 10.2.3 this is no longer an issue; however, I've still seen reports of it occurring.
So in general, it's best to leave applications where they were originally installed. If, like me, you hate the idea of opening /Applications and having to slog through files just to find the application you want to use, you'll appreciate Chapter 5, and the Online Bonus Chapter "Furthering Finder Frustration." I'll spend a good deal of time talking about other ways to access applications and files.