3

Assume we have one regular file and two symolic links connected to it. I heard that sometimes it's not possible to replace symbolic links with hard links, but I don't know when.

1 Answer 1

9

You can only create hard links between files in the same filesystem, whereas symlinks can point to absolutely anything (including stuff that doesn't exist at all).

Also you can't create hard linked directories on Linux, but you can do that with symlinks.

There's a corner case: you can only have up to a given number of hard links for a given "file". Don't know the exact limits (probably filesystem dependant). There is no such restriction on how many symlinks point to a given name.

2
  • Link limits I have see are in the range of 32k. The limit is not likely to apply in normal cases. Symlinks do use an Inode on most filesystems, so inode limits become an issue. Hardlinks do not create another inode.
    – BillThor
    Apr 18, 2011 at 16:08
  • Well there's the weird case of NTFS that's limited to ~2^10 but I'm not sure if feature is actually usable mounted on Linux. Good point about inodes.
    – Mat
    Apr 18, 2011 at 16:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .