24

I see that the size of alias is 167.7kB, whereas symbolic link is just 4kB.

  • What's the difference between the two, or what's the purpose of them?
  • Which one is preferable? For the case that the link/alias is used only in one machine or networked.

ADDED

http://prosseek.blogspot.com/2012/12/symbolic-link-and-alias-in-mac.html

26

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.

  • 11
    Another difference is that command-line tools (i.e. anything that uses Posix file APIs) won't understand aliases, just symlinks. Both will work for GUI applications. – Gordon Davisson Oct 7 '10 at 19:51
  • As I post in this post (apple.stackexchange.com/questions/2992/…), I found that the automator action doesn't work with link, but with alias. – prosseek Oct 8 '10 at 0:31
  • @sentinal you should add what hard links are as well – Mark Dec 10 '12 at 23:11
  • 1
    Notably, Spotlight won't index a symlink. It will index an alias (albeit at a lower ranking.) – ocodo Mar 28 '15 at 10:20
2

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

  • 1
    This appears to be a comment on an answer and not an attempt to answer the OP's question. Can you please explain how your post answers the original question? See How to Answer for guidance on writing good answers. - From Review – fsb Feb 14 '17 at 3:23
  • I answered OP's question by explaining how search on alias is worked on mac, that is, how path to file and UID is used in a search. The highly voted answer answered the difference but not answered why the difference is generated. – Izana Feb 15 '17 at 4:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .