1

Imagine I have a file something/a.txt, which I hardlink from b.txt. Now, if I cp b.txt c.txt, is c.txt a hard link to a.txt, or is it a copy of the contents of a.txt?

Misguided
  • 129

1 Answers1

8

Hardlinks are a completely different concept from other kinds of links or references.

A hardlink is another name to the same inode (a bit simplified: the file contents and metadata).

E.g. if you hardlink a.txt from b.txt, both names a.txt and b.txt are equal names to the same file. After hardlinking you cannot distinguish anymore if a.txt or b.txt was the original file name. Both names point to the same file.

That means cp b.txt c.txt will copy the file contents exactly as if you did cp a.txt c.txt.

cg909
  • 7,082