linuxinodehardlink

difference between /bin/ls and /usr/bin/ls


It seems that both /bin/ls and /usr/bin/ls have the same inode (and the same sha-256 hash) but the number of hard links displayed by ls -li /usr/bin/ls /bin/ls is 1 instead of 2 :

user@debian:~/Documents/Unix$ ls -lai /usr/bin/ls /bin/ls
8258848 -rwxr-xr-x 1 root root 147176 24 sept.  2020 /bin/ls
8258848 -rwxr-xr-x 1 root root 147176 24 sept.  2020 /usr/bin/ls

Could somebody explain me what I have misunderstood?


Solution

  • I was puzzled for a while by this too, until I discovered this:

    $ ls -ld /bin
    lrwxrwxrwx 1 root root 7 May 31 02:39 /bin -> usr/bin
    

    So /bin is just a symlink to /usr/bin, and there is really only one link to the file.