$ ln fun fun-hard
$ ln fun dir1/fun-hard
$ ln fun dir2/fun-hard
$ ls -1
total 16
drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir1
drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir2
-rw-r—-r—- 4 me 1650 2018-01-10 16:33 fun
-rw-r—-r—- 4 me 1650 2018-01-10 16:33 fun-hard
So there are 4 instances of the file fun Both the second fields in the listings for fun and fun-hard contains a 4, which now is the number of hard links that now exist for the file.
drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir1
drwxrwxr-x 2 me 4096 2018-01-14 16:17 dir2
Why there’s 2 instances of the file fun-hard on dir1 and dir2? Isn’t there’s only one hard link: fun-hard?
-rw-r—-r—- 4 me 1650 2018-01-10 16:33 fun
-rw-r—-r—- 4 me 1650 2018-01-10 16:33 fun-hard
Can you explain more these 4 instances of fun and fun-hard, why they are repeated?
There are 2 hard links on dir1 and dir2, if…:
-rw-r—-r—- 4 me 1650 2018-01-10 16:33 fun
-rw-r—-r—- 4 me 1650 2018-01-10 16:33 fun-hard
…there are 4 instances of hard links why dir1 and dir2 are not 4 instances also?
Why there’s 2 instances of the file fun-hard on dir1 and dir2?
The number of hard links to the dirs have absolutely nothing to do with the files they contain. – tkausl Jan 23 '24 at 23:31