find: Hard Links

1 
1 2.2.2 Hard Links
1 ----------------
1 
1 Hard links allow more than one name to refer to the same file.  To find
1 all the names which refer to the same file as NAME, use '-samefile
1 NAME'.  If you are not using the '-L' option, you can confine your
1 search to one filesystem using the '-xdev' option.  This is useful
1 because hard links cannot point outside a single filesystem, so this can
1 cut down on needless searching.
1 
1    If the '-L' option is in effect, and NAME is in fact a symbolic link,
1 the symbolic link will be dereferenced.  Hence you are searching for
1 other links (hard or symbolic) to the file pointed to by NAME.  If '-L'
1 is in effect but NAME is not itself a symbolic link, other symbolic
1 links to the file NAME will be matched.
1 
1    You can also search for files by inode number.  This can occasionally
1 be useful in diagnosing problems with filesystems for example, because
1 'fsck' tends to print inode numbers.  Inode numbers also occasionally
1 turn up in log messages for some types of software, and are used to
1 support the 'ftok()' library function.
1 
1    You can learn a file's inode number and the number of links to it by
1 running 'ls -li' or 'find -ls'.
1 
1    You can search for hard links to inode number NUM by using '-inum
1 NUM'.  If there are any filesystem mount points below the directory
1 where you are starting the search, use the '-xdev' option unless you are
1 also using the '-L' option.  Using '-xdev' this saves needless
1 searching, since hard links to a file must be on the same filesystem.
1 ⇒Filesystems.
1 
1  -- Test: -samefile NAME
1      File is a hard link to the same inode as NAME.  If the '-L' option
1      is in effect, symbolic links to the same file as NAME points to are
1      also matched.
1 
1  -- Test: -inum n
1      File has inode number N.  The '+' and '-' qualifiers also work,
1      though these are rarely useful.  Much of the time it is easier to
1      use '-samefile' rather than this option.
1 
1    You can also search for files that have a certain number of links,
1 with '-links'.  Directories normally have at least two hard links; their
1 '.' entry is the second one.  If they have subdirectories, each of those
1 also has a hard link called '..' to its parent directory.  The '.' and
1 '..' directory entries are not normally searched unless they are
1 mentioned on the 'find' command line.
1 
1  -- Test: -links n
1      File has N hard links.
1 
1  -- Test: -links +n
1      File has more than N hard links.
1 
1  -- Test: -links -n
1      File has fewer than N hard links.
1