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

Home > Articles > Apple > Operating Systems

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.

    SEE

    "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.

SEE

"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.

SEE

  • "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.

NOTE

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.

SEE

"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.

NOTE

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.

TECHNICALLY SPEAKING

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.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020