I have a bash script in two places and I can't remember how I created them. they have the same inode but none of them seem to link to another. is there a hard link but should not Links count for that inode become two?
$ ls -l ~/bin/dropbox-backup
-rwxr-xr-x 1 bak bak 676 Aug 14 09:32 dropbox-backup
$ ls -l ~/Dropbox/linux/scripts/dropbox-backup
-rwxr-xr-x 1 bak bak 676 Aug 14 09:32 ~/Dropbox/linux/scripts/dropbox-backup
$ stat ~/bin/dropbox-backup
File: `dropbox-backup'
Size: 676 Blocks: 8 IO Block: 4096 regular file
Device: 806h/2054d Inode: 528738 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1001/ bak) Gid: ( 1001/ bak)
Access: 2013-08-14 20:40:25.599322386 +0100
Modify: 2013-08-14 09:32:47.748546462 +0100
Change: 2013-08-14 20:40:25.591322386 +0100
Birth: -
$ stat ~/Dropbox/linux/scripts/dropbox-backup
File: `/home/rag/Dropbox/linux/scripts/dropbox-backup'
Size: 676 Blocks: 8 IO Block: 4096 regular file
Device: 806h/2054d Inode: 528738 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 1001/ bak) Gid: ( 1001/ bak)
Access: 2013-08-14 20:40:25.599322386 +0100
Modify: 2013-08-14 09:32:47.748546462 +0100
Change: 2013-08-14 20:40:25.591322386 +0100
Birth: -
Best Answer
The files have the same inode and are on the same filesystem. You can see that in the output of
stat
: it reportsDevice: 806h/2054d Inode: 528738
for both files. All native unix filesystems report distinct inodes for distinct files (this may not be guaranteed for some remote or foreign filesystems).The two names for the files do “link to each other”, or more properly speaking, they lead to the same file.
~/bin/dropbox-backup
and~/Dropbox/linux/scripts/dropbox-backup
are the same file. The most likely explanation is that~/bin
is a symbolic link to~/Dropbox/linux/scripts
or vice versa, so that you're reaching the same file through two different directory and symbolic link chains.You can check that by comparing the canonicalizations of the two paths (i.e. the paths with all symbolic links resolved):