Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Apple > Operating Systems

  • Print
  • + Share This
This chapter is from the book

Aliases and Symbolic Links

An alias is a file that is pointer to a real (original) file located somewhere else. Thus, when you double-click an alias, the other (original) file opens. By using aliases, you can list the same file in many locations without having to have real copies of the file in each location, which provides convenient flexibility in organizing files on your drive.

For example, suppose that you have a collection of applications at various locations on your drive, and you want to bring them together in the same folder for a specific task. Yet you also want to retain them in their original locations. You can do both things by creating aliases of the files and placing the aliases in the new location. Now whenever you click an alias, it launches the original file, as though the file were in two locations at the same time. As the alias takes up next to no disk space, this arrangement is often more advantageous than having two copies of the full application.

You can use aliases in other ways, such as the following:

  • Sometimes, a program may look for a preferences file in the startup System Folder (in Classic). If you have different startup System Folders, the preferences may be different in each case. You could prevent this problem by placing an alias of the original preferences file in each of the other System Folders. Now all the folder will use the same preferences file, no matter what changes you make at what time.

  • If you place an alias of a folder in a new location, when you open the alias folder, the original folder actually opens. By placing such an alias in a convenient location, you get instant access to the folder contents, even though the folder may be nested several folders deep in some other location.

  • Making an invisible folder temporarily visible and making an alias of it is a useful trick for maintaining easy access to folders that normally are invisible. You can use this technique to maintain access to the invisible tmp folder, for example.


    "Saving movie trailers that have the Save option disabled," later in this chapter, for an example of using this tmp folder.

How to recognize an alias

The icon for an alias looks identical to that of the original file, except that that a small arrow appears in the bottom-left corner of the icon.

An alias also behaves differently when you open the Show Info window for the file. The differences are:

  • A button called Select New Original will be in the main Show Info window. Clicking this button allows you to change the file attached to the alias. You will not need to do this often unless the original file has been deleted.

  • The Kind setting for the file may be alias, and the Size setting of the file will be only 4 KB. I say "may" because in what appears to be a bug, an alias file may instead list the original file's kind as its own and be listed with a larger size. In this case, the Select New Original button will be the main clue that you are dealing with an alias.

    Figure 6.27Figure 6.27 An alias file and its Show Info window.

How to locate an original via its alias

What if you want to locate the original file from its alias? First, right above the Select New Original button will be the path to the original file. You can navigate there on your own.

More simply, you can choose Show Original from the Finder's File menu (or use the keyboard shortcut Command-R). The Finder will go directly to the folder where the original is located and display it with the file selected.

How to create an alias

To create an alias, click the original file and choose Make Alias from the Finder's File menu (or use keyboard shortcut Command-L). Alternatively, you can choose Make Alias from the contextual menu for the file.

Which ever method you select, an alias will be created in the same location as the original file—with the word alias added to its name. (The word will precede the file's extension, if it has one.) Then you can rename or move the alias, as you want. The alias's relation to the original file will be preserved no matter where you move either file, at least as long as you stay in the same volume.

Often more conveniently, you can hold down the Command and Option keys and drag the file's icon to a new folder. This technique creates an alias at the new location with the same name as the original. (The word alias is not added.)

When you use the Add Favorites command to add an item to your Favorites folder, you are creating an alias of the item.

Fixing a broken alias link

If you delete the file to which an alias is linked or move or modify the file so that the alias can no longer locate it, you will get an error message when you double-click the alias file. This message will state, "The alias {name of file} could not be opened because the original item could not be found." This situation is called a broken alias.

At this point, you can click OK (thereby ignoring the issue for the moment), Delete Alias (with the obvious result), or Fix Alias. This last option opens a window similar to what appears when you click Select New Original in the Show Info window. From here, you can navigate via a directory window to the desired destination file and select it as the destination for the alias.

Figure 6.28Figure 6.28 The broken-alias error message.

Aliases vs. symbolic links:What's the difference?

If you are familiar with Mac OS 9, much of this alias discussion probably has a familiar ring, as aliases work in a similar way in Mac OS 9. But Mac OS X introduces a new wrinkle, compliments of Unix. Unix includes something similar to aliases: symbolic links. When you're in the Mac OS X Finder, a symbolic-link file looks and acts almost identically to an alias file, with these exceptions:

Aliases are linked to the file or folder to which they point. If you move the original file to a new location, the alias is able to keep track of this situation and maintain the link. When you double-click the alias, the original file still opens.

Symbolic links refer to a specific pathway. Thus, for example, a symbolic link to a file called Testing in your Documents folder will work only if Testing remains in the Documents folder. Move it anywhere else, and the link is broken. Just as important, if you move or delete the original file and create a new file with the same name in the original location, the symbolic link will point to that new file (because it has the same pathway). An alias would not do this; it would not link to the new file despite its identical name.

When you install Mac OS X, the OS places symbolic-link files in various locations, including inside the Library folders, inside application packages, and in the invisible Unix directories. As these locations are off the radar of most users, the typical Mac user rarely needs to work with symbolic links. Symbolic links may also appear in more commonly visited locations, where they will seem to be just ordinary aliases. As I'll describe a bit later in this chapter, there may be one such symbolic link on your Desktop.

If you want to create a new alias, my general recommendation is to stick with the traditional Mac variety. Aliases are easier to create than symbolic links are, and they generally work more the way you would expect. But if you want an alias always to refer to a file with a specific name in a given location, whether or not the file has been replaced, a symbolic link will do the trick. To link to a file that gets overwritten by a new file with the same name periodically, you would want a symbolic link.

Still, an alias link may break in a situation in which a symbolic link would be maintained, and vice versa. For this reason alone, at least understanding the distinction is useful.

Finally, if you format a drive by using UFS (which I do not recommend) rather than HFS Plus, the Mac will not recognize aliases; it will recognize only symbolic links.


"Select a destination," in Chapter 2, for more information on UFS vs. HFS.

Determine whether a file is a symbolic link or an alias

You cannot tell from Finder icons whether the file is an alias or a symbolic link. Both types of files have the same icon with the curved arrow.

Even the Show Info window for the two types of files does not offer an obvious answer, as both types may be identified with a Kind setting of alias. In my experience, however, the Select New Original button will be dimmed, and thus not selectable, for symbolic links. For traditional aliases, the button is selectable, meaning you can use this difference to distinguish between an alias and a symbolic link.

Another way to determine whether a file is an alias or a symbolic link is to move the original file and then double-click the alias. If the original file still launches, you have a traditional alias. If you get a message that says the original could not be found, without the usual Delete Alias and Fix Alias options, you have a symbolic link.

Yet another, more-tedious way to figure this out is to reboot in Mac OS 9. In that OS, traditional aliases are identified in the Finder's Get Info window as having a Kind setting of alias, whereas symbolic-link files will be identified as Mac OS X alias. In Mac OS X, both types of files are identified simply as alias.

As I describe in the next section of this chapter, symbolic links also differ from aliases in terms of how they are listed in Terminal.

Figure 6.29Figure 6.29 The message that appears when a symbolic link cannot find its original file.

Create a symbolic link

Any alias that you create via the Finder's Make Alias command is a traditional alias. What if you want to create a symbolic link instead? You have two choices: take the Terminal or the Mac OS X utility (such as XRay) approach.

Terminal. To create a symbolic link in Terminal, follow these steps:

  1. Launch Terminal.

  2. Type <ln -s {pathway of original file} {pathway of symbolic link}>. Note: Use an absolute pathway for the original file, not a relative one. A shortcut for adding the absolute pathway is to type ln -s, a space and then drag the Finder icon of the original file to the Terminal window.


  • "Take Note: Folders vs. Directories," in Chapter 4, for background on absolute vs. relative pathway names.

  • Chapter 10 for more information on pathways and shortcuts in Unix.

You can now navigate to the directory where you created the link (via Unix's cd command), and type <ls –al>. This will result in the display of a list of all items in the directory, including symbolic links. Notice two things in the list:

  • In the file-attributes column (where permissions are indicated), the first letter listed for a symbolic link file is l (rather than d for directory or a hyphen for files).

  • For symbolic-link files, the path to the original file will be listed to the right of the file name. Traditional aliases have neither of these attributes.

Now if you go to the Finder, the symbolic-link file should appear in the same directory as seen in Terminal. If it does not, search for it via Sherlock and then double-click its name in the Search Results output. This method will force it to show up. As a last resort, log out and log in again.

XRay. To create a symbolic link with XRay, follow these steps:

  1. Open the original file with XRay and then choose Make Alias from its File menu.

  2. In the window that appears, from the Alias Format menu, choose Normal Alias, Absolute Symbolic Link, or Relative Symbolic Link.

Ignore the rarely needed Relative Alias and Minimal Alias options. With an absolute symbolic link, any movement of the original file to a new location will break the link. With a relative symbolic link (most commonly used in Mac OS X packages), the link will be maintained if both the link file and the original file are always in the same relative locations within a folder, even if that folder is moved. This arrangement allows you to move an .app package file (which is actually a folder)—that contains symbolic-link files to other files within the package—without breaking the links.

Again, the link file should appear in the Finder at this point.


The current version of XRay cannot show the permissions for a symbolic link correctly; instead, it lists the permissions of the original file. Thus, you cannot use XRay easily to check whether an alias is a symbolic link.

Figure 6.30Figure 6.30 XRay's option to create symbolic links.

"Desktop (Mac OS 9)" file is a symbolic link

An alias file called Desktop (Mac OS 9) is placed on the Desktop on Macs that ship with Mac OS X and Mac OS 9 installed on the same volume. This alias is of value because the Mac OS 9 and Mac OS X Desktops are entirely independent. That is, what you place on the Mac OS 9 Desktop (when you're booted in Mac OS 9, for example) and what you place on the Mac OS X Desktop are stored in different locations. Thus, the items from one Desktop are not visible when you're viewing the other. Furthermore, accessing the contents of the Mac OS 9 Desktop, when you're booted in Mac OS X, is complicated by the fact that the Mac OS 9 Desktop folder is invisible in Mac OS X ( located at the root level of the volume). The Desktop (Mac OS 9) alias allows you to work around this situation. When you open it, a window opens, showing the contents of the invisible Mac OS 9 Desktop. The contents are visible even though the folder itself is not.

If you have partitioned your drive into multiple volumes, you will not need a separate similar alias for the Desktop folders of the other volumes, because the Desktop folders for these volumes remain visible on these volumes. These folders contain the files from these volumes that appear on the Desktop when you're booted in Mac OS 9. Thus, the Desktop (Mac OS 9) folder shows only the Desktop items that are stored on the Mac OS X boot volume.

Why am I mentioning all this in this section of the book? Because the Desktop (Mac OS 9) alias is actually a symbolic link. I am not sure what Apple's rationale was in making this item a symbolic link. Perhaps Apple did not want it to continue to work if you moved the Desktop folder elsewhere. In any case, if you delete this alias/symbolic link accidentally, you will have double trouble trying to re-create it. First, the original folder is invisible (although, as I discuss later in this chapter, you can access invisible items in several ways). Second, using the Finder's Make Alias command would create a traditional alias, not a symbolic link. So duplicating the original alias takes a bit more work. The simplest way probably is to use Terminal. Follow these steps:

  1. If the symbolic-link file is present but broken, delete it; if it is deleted, proceed to the next step.

  2. Launch Terminal, and type:

    < ln -s /"Desktop Folder" ~/Desktop/"Desktop (Mac OS 9)">

  3. Press Return.

  4. Click the Desktop.

The new symbolic-link icon should appear.


"Take Note: The Location of Desktop and Trash Folders," in Chapter 3.

Symbolic links and hierarchical menus in the Dock

If you drag a folder icon, or even a volume icon, to the Dock, you create a Dock item for that folder/volume. The main benefit is that if you click the Dock icon of the volume and hold down the mouse button, you will get a hierarchical pop-up menu of all the folders and files in the folder/volume. You can choose any item to open it.

If the volume contains an alias file pointing to a folder, the alias will work in the Dock icon's pop-up menu as though it were the original folder itself. Its submenu will show the contents of the original folder.

This technique appears to work only for traditional aliases, however. If the alias is actually a symbolic link, you will see only the name of the folder listed. You will not be able to view its contents hierarchically.

To see an example, drag the Favorites folder to the Dock. (The folder is located in the Library folder of your Home directory.) A Documents folder alias is placed in Favorites automatically when you install Mac OS X. This alias is actually a symbolic link. Thus, the pop-up menu will not list the contents of the Documents folder.


In the first versions of Mac OS X, the situation was reversed. Symbolic links were the ones that showed submenus; traditional aliases did not.

Figure 6.31Figure 6.31 The pop-up menu from the Favorites folder in the Dock. Note that the Documents icon does not show a hierarchical menu.

Fixing a broken symbolic link

What if you click a symbolic-link icon and find that it is broken (you get the error message that the original file cannot be found)? In most cases, to fix the link, you create a new symbolic link file, using the ln command in Terminal, as described earlier in this chapter.

A potentially more serious problem involves the multitude of symbolic links that exist in package files, Library folders, and invisible Unix directories. If these links get broken, you may have problems that range from the failure of an application to work to inability to start up Mac OS X. You want these problems to be fixed. Fixing them, however, is not a trivial task, as you may have trouble locating the problem files and reestablishing the links correctly, especially if the problem is preventing you from starting up your Mac.

To fix these problems, try these methods:

Disk repair utilities. You may get some help from disk repair utilities such as Norton Utilities. If you have broken symbolic or hard links in the Unix directories, for example, run Norton Utilities (booting from its CD or from a Mac OS 9 volume, if you are not using the Mac OS X version). The utility attempts to fix the problem.

Reinstall Mac OS X. Otherwise, you will likely need to reinstall the problem applications or Mac OS X itself.

SEE: Chapters 2 and 5 for advice on reinstalling Mac OS X.

How, you may ask, do these links get broken in the first place, assuming that you made no obvious change that should have caused any breakage? There are several possibilities, including the following:

  • If you back up and restore files via a backup utility, symbolic links may get broken unless the backup utility specifically knows how to restore these links. (The best-known Mac backup utility, Retrospect, does handle this restoration correctly.)

  • Archiving a folder/directory and later expanding it can cause problems unless the archiving utility knows how to handle the process. (At this writing, StuffIt Deluxe still has some problems.)

  • An installer for an application, if not designed correctly, could move files during the installation in such a way that symbolic links get broken.

There is a relatively rare but significant problem with the .pax files that are contained in installer packages (see Chapter 2). If an installer .pkg file (likely one from a third party, not Apple) writes to the invisible Unix files on your drive (such as the etc directory), it may do so in such a way that it breaks existing symbolic links to these directories. In extreme cases, this situation can result in the failure of your drive to start up, ultimately requiring a reinstallation of Mac OS X unless you are skilled enough to recognize and fix the broken symbolic links or have a third-party utility that can do it.

There is no sure way to prevent these problems other than not using the software in question or checking online (such as MacFixIt or the software vendor's Web site) before using a backup/archiving/installation utility to determine whether it has any known problems with symbolic links.


Unix Hard Links

A hard link in Unix is a duplicate directory entry for a file. Even if you delete the original file, the hard link will still access the file's contents, because the original file and all its hard links point to the same data. Think of the data as being stored somewhere on your drive and the original file as being just a pointer to the data. Then a hard link is another pointer to the same data. I am not aware of any case in which a hard link is used in the Finder. so hard links are relevant mainly for the workings of the invisible Unix files. About the only time they may become relevant for troubleshooting is when you're attempting to copy a Mac OS X volume to another drive. As is the case with symbolic links, the copy procedure will need to be able to maintain the hard links correctly.

  • + Share This
  • 🔖 Save To Your Account