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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lets say, when I do ls -li inside a directory, I get this:

12353538 -rw-r--r-- 6 me me 1650 2013-01-10 16:33 fun.txt

As the output shows, the file fun.txt has 6 hard links; and the inode number is 12353538.

Given the case, how do I find all the hard links for the file i.e. files with the same inode number?

share|improve this question
up vote 15 down vote accepted
find -samefile /mount/point/your/file
share|improve this answer
@TheoneManis I just noticed that the other parts of the find call are not necessary. find is clever enough to use them implicitely. Usually you have to give find a search path and have to tell it that is shall not leave these file systems (via symlinks or mount points). But when looking for hard links it's clear on which file system to search. – Hauke Laging Apr 24 '13 at 13:51
Got it. Thanks for the explanation. :) – its_me Apr 24 '13 at 13:54
Hauke, that depends on the version of find you're using. The GNU version might do that, but the BSD one does not, and this will not work as-is on Mac. – Alan Shutko Apr 24 '13 at 19:36
You may want to add -xdev to avoid descending into directories in other filesystems, otherwise you might find another file with the same inode number located in another filesystem. – mmoya Nov 17 '13 at 17:46
The near-equivalent to -samefile on HP-UX is -linkedto (though it is slightly different: a search path must still be specified, for example). – Dominick Aug 27 '15 at 19:37

If you already have the inode number you can use find's -inum option:

find -inum 12353538
share|improve this answer

With GNU find you can search by inode number directory. For example, to find all files with inode number 12353538:

find . -inum 12353538 -print
share|improve this answer
If the expression contains no actions other than -prune, -print is performed on all files for which the expression is true. – Jakuje Jan 10 at 15:36
I'm not entirely sure what value this answer brings, as there's already an answer offering this solution. – roaima Jan 10 at 16:13

Your Answer


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.