Finding the Link, the Hard Link

Heinrich Rebehn rebehn at ant.uni-bremen.de
Wed Mar 15 14:56:25 UTC 2006


David Walker wrote:
> OK, sorry for the sappy subject but oh well.
> 
> So I am having a question and problem.  What I am doing is writing a 
> script to parse over 2 loop file systems, and check for changes.  
> Simple, no?  Well I thought so until I ran into the HardLink.  This 
> would be able to be ignored and just put 2 copies of the file in the 
> loop filesystem, however we are pressed for space and every 4k matters.  
> So I ask, is there a way to tell the difference between the real file, 
> and a hard link?

No, since both are equivalent.
> 
> eg.
> /etc/passwd and /etc/passwd.hl
> 
> The .hl was made with ln, now how can I tell that it is, or was made 
> with ln, a hard link?
> 
> -- 
> Dave
> 
ls -l will show you the number of links (2nd item), if it is > 1 then 
there is another link pointing to the same file.

ls -i /etc/passwd /etc/passwd.hl will show you that both files point to 
the same inode.

-- 

Heinrich Rebehn

University of Bremen
Physics / Electrical and Electronics Engineering
- Department of Telecommunications -

Phone : +49/421/218-4664
Fax   :            -3341




More information about the ubuntu-users mailing list