Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer
    
So, an appropriate metaphorical interpretation would be that a soft link is just a file shortcut while a hard link is a synchronized copy of the file? –  Iszi Jul 3 '13 at 1:27
    
Well ... keep in mind a hardlink doesn't really make an additional copy of the data of the file. It's another physical directory entry. So two hardlinks to a file won't change the disk space used very much. –  ultrasawblade Jul 3 '13 at 1:58
    
If you're savvy with programming concepts, think of a soft-link as a traditional pointer, and hard-link as a reference-counted (smart) pointer. –  paddy Jul 3 '13 at 2:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.