What's the difference between alias and link?

An alias contains two pieces of information: a unique identifier of the file it links to, and the path and file name of the file it links to.

If you rename or move a file, and then create a new file with the path and file name that the file originally had, then any alias that linked to the original file now links to the new file.

However, if you rename or move a file without replacing it, and then invoke an alias, the alias is updated to point to the new path and file name, making use of the unique identifier to do so.

A symbolic link, on the other hand, does not contain a unique identifier to a file, and would appear as broken if the file is renamed or moved and not replaced with a file of the same path and file name.

Your choice should depend on which scenario suits you best.


I'm quite confused by sentinel's anwser on create a new file with the path and filename that the file originally had. Also it's abrupt, why you want to do that?

Well, if you understand why and how alias works on using UID and path to the file (while symlink only works on the path), then you can understand the difference and the highly-voted answer more easily.

On HFS and HFS+ file systems, each file and folder has a unique, persistent identifier. Aliases use this identity along with pathname information to find files and folders on the same volume.

Beginning with Mac OS X 10.2, aliases reversed this search order by using the pathname first and unique identity second. This means that if you move a file and replace it with an identically named file, aliases to the original file now point to the new file. Similarly, if you move a file on the same volume (without replacing it), aliases use the unique identity information to locate the file.

When a file or folder moves, the alias may update either its path information or unique identity information to account for the change. If a file moves somewhere on the same volume, the alias updates its internal record with the new path information for the file. Similarly, if the original file is replaced by a file with the same name, but a different unique identity, the alias updates its internal record with the unique identity of the new file. (result of create a new file with the path and filename that the file originally had)

Because aliases use a file system path to resolve a files location initially, they now offer a similar behavior to symbolic links. Symbolic links rely exclusively on path information to locate a file. If you move a file somewhere on the same volume without replacing it, symbolic links to the file break while aliases do not. The only way to fix a symbolic link is to delete it and create a new one.

reference