When should I use hard links as opposed to soft links?
I'm about to start toying around with mklink
but I'm still trying to get a real grip on this whole "symlink" thing. In particular, I've noticed there's two types of links - "soft links" and "hard links" - but I'm having a hard time truly understanding the difference between the two, or why I should prefer one over the other for any given use case.
The most I've been able to glean so far is this:
- Soft Links are treated as pointers to the target file/folder.
- Hard Links are treated as if they actually were the target file/folder.
What does this really mean in terms of how the OS and applications will treat the links? What factors should be weighed when deciding whether to use one or the other?
The current use case I have is for getting SkyDrive to synchronize files/folders that are outside of the actual SkyDrive directory. However, I would prefer if answers could also include general guidelines for future reference.
It's possible to have dangling softlinks, since a softlink is a pointer to a file.
It's not possible to have dangling hardlinks. Each file has at least one hardlink, i.e. directory entry in the filesystem. Thus, if you create a file, and then a hardlink to it, and then delete the original file, the hardlink will be unaffected.
Because of this, hardlinks may lead you to believe when you've deleted a file that it's really gone, although unless you delete ALL hardlinks, the file will still exist. Most of the time you want to use softlinks unless you want to take advantage of this specific aspect of hardlinks.