Sunday, June 10, 2007

Links and symlinks - Unix and Windows

Hard links in Unix are files that have different names and can possibly different directories, but they have same inode i.e. the file is stored at any one place in the hard disk. All the hard links to any file point to that location. One can delete a hard link but it won't delete the file if there is any other link to it.

Symbolic links or symlinks on the other hand are small file that contain the pointer to another file. They are different from the actual file they are pointing to. So deleting a symbolic link won't delete the actual file. The implementation of symbolic links in Unix is transparent to the user. If a user opens and edits a symbolic link, he actually is editing the file the symbolic link points to. The symbolic link remains just a pointer to the actual file.

While Windows have shortcuts that are nearest thing to symbolic links, if someone edits a shortcut file, it actually gets changed and so it is not as transparent to the user as Unix. I read somewhere that Windows Vista has introduced transparent symbolic links similar to Unix.

1 comment:

Craig said...

NTFS in Windows XP supports hard links. It also supports what are essentially limited symbolic links pointing only to local directories.
See:
http://answers.google.com/answers/threadview?id=341355

It sounds like junctions (IIRC also known as "reparse points") are a lot more like bind mounts than symlinks.

True symlinks do seem to be new to Vista:
http://en.wikipedia.org/wiki/NTFS_symbolic_link