I hear that you can now create soft links in Vista too. So, what is the difference between a soft (symbolic) link and a hard link on UNIX/Linux/Vista?
Are there advantages of using one over the other? Or do they just serve two distinct purposes?
|
I hear that you can now create soft links in Vista too. So, what is the difference between a soft (symbolic) link and a hard link on UNIX/Linux/Vista? Are there advantages of using one over the other? Or do they just serve two distinct purposes?
| |||||||
feedback
|
|
A hard link traditionally shares the same file system structures (inode in unixspeak), while a soft-link is a pathname redirect.
(Some details brought back to mind by mat1t. Thanks.) | |||||||||||||
feedback
|
|
The summary is that a symbolic / short link acts as a shortcut to the first file's location, whereas a hardlink is a shortcut to the file on the disk. If you delete the target of a soft link then the soft link will cease to work, but if you delete one copy of a hard link, the file will remain on the disk until all hard links to it are removed. In effect all filenames are hardlinks to the file on the disk. There are also certain restrictions, eg I don't think you can create hard links of folders, but you can create soft links of them. Soft links can also point to files/folders on different drives and partitions whereas hard links can't. | |||
|
feedback
|
|
dmckee's answer has the details about the semantics pretty much exact. The only detail I would add is an explanation of what happens at a higher level: a soft link is a file on its own, while a hard link is a directory entry pointing to existing data. | |||
|
feedback
|
|
In practical terms, the answer is that you almost always want to use a symbolic link. My understanding is that hard links are mostly for preserving space, especially in things like snapshots and incremental backups, where successive snapshots have many identical files that are unlikely to change in the future. | |||||||
feedback
|
|
The MS Windows system always uses soft links (shortcuts). That is, the link simply acts as a shortcut pointing to the file location. If the location of the original is moved, the link breaks. Furthermore, what you do to the shortcut (such as changing permissions, or changing the name of the shortcut) does not affect the actual file. So the question started with an incorrect assumption. Yes, Vista uses softlinks, but it is not new, that is waht an MS shortcut is. | |||
|
feedback
|
|
We can not create Directory Hard Link because same inode no is associated with parent directory that is reserved by system. when we create directory then are default directory created . & .. that symbolize for current directory & parent directroy.Suppose parent directory inode no is 10 , now try to create child dir under this then .. directory inode will 10. That's why we can't create dir hard link. | |||||
feedback
|