Windows 7: hard link, symbolic link and junction [duplicate]

Possible Duplicate:
What is the difference between NTFS hard links and directory junctions?

What's the difference between them? in examples..


Solution 1:

The easiest way for most people to understand a symbolic (or soft) link is to think of it as a Windows shortcut.

If you make a symbolic link to a file, when you open it, Windows goes and looks up the original file in the filesystem index and then opens it. You can think of the symbolic link as being a signpost to the original file.

A hard link is an extra entry in the filesystem index that points to the same location on the disk as the original file's name. Think of the original name and the hard link as two doors into the same room.

A junction is a symbolic link to a folder (I think this is a hangover from previous versions of Windows and is now obsolete - I presume, but I haven't checked, that you can just use hard links now).

Solution 2:

Directory Junction is "symlink to directory", so you can create "access points" to folders, available since NTFS 5.0 (Windows 2000). Directory Junction is NOT "a hard link to a folder", because junctions can point to non-existent directories. Directory and its junctions can be located on different NTFS partitions, but not across LAN. Non-elevated admins & user can create junctions.

NTFS Symbolic link was added to NTFS in Windows Vista. Symbolic link can point to a file or a directory (compare with junctions). Using them you can create "access points" to files & folders on different NTFS partitions AND across LAN. "The default security settings in Windows Vista disallow non-elevated administrators and all non-administrators from creating symbolic links."

"Symbolic link to directory" vs "Directory Junction" - by my experience, some (many?) apps does not work correctly with symbolic links, but they are fine with junctions, e.g. Total Commander and Windows file sharing (for LAN). If you share a directory with symlink - LAN users cannot traverse it, but they can do it for junctions. So after high-quality thing in Win2k, MS implemented some stuff in Vista...

Hard links can point to files only in the same partition, there is absolutely no difference between first file instance and other hard links to the same file. If you delete some hard link (first instance or another), file will continue to exist unless last hard link is deleted.

Junctions & symbolic links can be "broken" - it you rename/move the target, then they will point to non existent target. So you need to update they in such cases. But hardlinked files can be renamed/moved and all hardlinks will still be the same file, just with different names.