Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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: -
share|improve this question
2  
Maybe there is a link in the path? What filesystem? –  frostschutz Aug 14 '13 at 20:09
1  
Yes, like ~/Dropbox/linux/scripts being a symlink to ~/bin. Run namei -l on both files. –  Stéphane Chazelas Aug 14 '13 at 20:11
    
@Stephane: you are correct. ~/bin is a symlink to ~/Dropbox/linux/scripts. thanks. –  rag Aug 14 '13 at 20:17
    
@Stephane I'll leave you to post the correct answer and retract my nonsense :) –  Drav Sloan Aug 14 '13 at 20:24
    
DravSloan, I'll leave that to @frostschutz as he pointed it out first :-) –  Stéphane Chazelas Aug 14 '13 at 21:24

1 Answer 1

up vote 2 down vote accepted

The files have the same inode and are on the same filesystem. You can see that in the output of stat: it reports Device: 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):

readlink -nf ~/bin/dropbox-backup ~/Dropbox/linux/scripts/dropbox-backup
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.