Aliases and links

Aliases and links both allow you to create other names for the same file and even have those names in other directories. You can have "/Users/you/fred" and "/Users/you/desktop/stuff" be the same thing: edit either one and you'll see the changes in the other.

There are actually three forms of linking in Mac OS X: aliases, hard links, and symbolic links. These are all really file system features, but HFS+ supports all three, and for the example given above, all three are identical.


Hate these ads?

But there are differences. Hard links come over from the Unix world, and are simply directory entries pointing to the same inode. The inode is the traditional Unix metadata that has information about permissions, ownership and disk blocks used; if two directory entries point to the same inode, they are pointing to the same file. Technically HFS+ file systems don't have inode tables. However,just about everything works as though they did. See Usenix2000 invitedtalks sanchez_html/) and Apple.com technotes

A hard link can't refer to a directory (because it would just be too easy to completely screw up the file system) and it can't refer to a file on another file system (because inode numbers are only unique to an individual file system).

A symbolic link is again from Unix, but is really just a text file that contains the path to another file. Its metadata is marked so that that path is interpreted rather than being seen as text. A symbolic link can refer to a directory, a file on a different file system, or even another symbolic link.

Aliases are a Mac invention, and are similar in concept to symbolic links, but don't depend upon the original path name to find the "real" file. It uses a "unique identity" instead. If you renamed or moved a file referenced by a symbolic link, the link would be broken and would not work, but an alias still would.

If you stay away from the command line, your Mac will always do the "right thing" with regard to aliases, but you can get confused if you mess with aliases in Terminal. You cannot "see" the original file with ordinary terminal commands; if "fred" is an alias for "tom", "cat fred" will come up empty. You can "vi fred", but whatever you put in there won't change "tom" in any way.

Interestingly, an alias does store path name information, apparently as redundancy: if the file can't be found from the unique identity, OS X (the file system driver, really) will try to find it by path name. There seems to be confusion in some documentation; Apple documentation says:
 







 In versions of Mac OS X before 10.2, aliases located a file or folder
 using its unique identity first and its pathname second. 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 identify
 information to locate the file.


 
 When a file or folder moves, the alias may update either its path
 information or unique identify 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.
 

Note that the difficulties that come from moving with aliases are only confusing when moving the original to a different file system.


Technorati tags:



Comments /foo-mac/links-and-aliases.html




Add your comments

LOD Communications, Inc.

Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner


Views for this page
Today This Week This Month This Year  Overall
1126968 3,096

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

pavatar.jpg
More:
       - MacOSX




Unix/Linux Consultants

Your ad here - $24.00 yearly!

http://thatitguy.com Business networking servers, Linux and Unix experts. In business since 1997! Windows and Exchange to Samba and Scalix migration experts.


http://www.schewanick.com SCO Unix, Solaris, Linx (various), PHP, MySQL, Apache, uniBasic, dL4, Perl, System Administration and more....


UBB Computer Services Support for Openserver, Unixware and Linux. Windows integration with Unix/Linux servers. Hardware, Backup and Networking issues. Located near Sacramento CA, we provide onsite support throughout Northern CA and Nationwide via remote access. We are a SCO Authorized Partner and a Microlite BackupEdge Certified Reseller.









Change Congress


Related Posts