if you change the content for both the original file or the hardlink, the content is changed in the original file (thus changed in the hardlink). if you change the content in a copied file, the original file doesn't change its content. just the file you decided to edit.
-bash-3.00# echo test >> orig.file
-bash-3.00# cat orig.file
test
-bash-3.00# ln orig.file hardlink.file
-bash-3.00# cat orig.file
test
-bash-3.00# cat hardlink.file
test
both files have same content
-bash-3.00# echo hard test >> hardlink.file
-bash-3.00# cat hardlink.file
test
hard test
-bash-3.00# cat orig.file
test
hard test
edit hardlink.file and all content changes
-bash-3.00# cp orig.file copied.file
-bash-3.00# cat copied.file
test
hard test
-bash-3.00# echo copy test >> copied.file
-bash-3.00# cat copied.file
test
hard test
copy test
-bash-3.00# cat orig.file
test
hard test
-bash-3.00# cat hardlink.file
test
hard test
change to copied file doesn't show same with original file but hardlink and orig file show same content.
This is incorrect, hard-linking occupies almost no more space (just metadata) while copying (unless you are using ZFS deduplication which is quite unlikely at that time) will double the space usage.
Think of a hard link as a pointer in the filesystem. Just like in C, it has to be dereferenced. But instead of what a pointer does: refer to a separate place in memory, with a hardlink we are referred to a place on the physical disk. The link acts as a proxy for the "real" filename.
The C pointer uses very little memory, but can reference a giant object in memory.
A hard link uses very little disks space but can reference a huge file.
How hard links are implemented is not by a universally defined object, but is up to the filesystem and the drivers to resolve. This is like C: a pointer can be a "big-endian" or a "little-endian" object in memory, and the compiler works out how to reference the object the pointer is "aimed" at. The filesystem + driver does the same. We do not worry about how to figure it out at all.
Links have consequences. One of them is that you do not ever want dangling links - links "aimed" at non-existent. It is possible to create a series: link -> link -> physical file. This is where it is easy to get in trouble. You can create circular links in some circumstances.
Copy duplicates a whole file. Link references a whole file.
In really old filesystems it was possible. Ever see a hard-linked directory? It is not allowed now. Read up on it if you want. Why would such a thing be mentioned or considered a problem, you ask?
You are right, dangling hard-links are actually still possible. For example when using ufs with journaling disabled and after a filesystem corruption or simply after running the clri command.
I though you were confusing with symbolic links because your circular link example "link -> link -> physical file" is something quite hard to achieve with hard-links (hardlinks refer to inodes, not files) but quite common with symlinks.
---------- Post updated at 10:14 ---------- Previous update was at 10:10 ----------
They point to different things.
A hard-link point to actual data while a symbolic (or soft) link point to a filename / path that may exist or not.
If you remove a hard-link, there will be no way to refer to the data unless other hard-links still exist to the very same data while if you remove a symlink, you don't loose data, just a way to refer to it.