Super User is a question and answer site for computer enthusiasts and power users. 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

How can I use the inode number to locate all hardlinks to the file "file.txt" in my home directory?

share|improve this question

To find all files in your home directory with inode number N, use either

find ~ -maxdepth 1 -inum N

(home directory only) or

find ~ -xdev -inum N

(includes subdirectories).

The switch -xdev prevents finding files with the same inode number on different file systems, since they're not the hardlinks we're looking for.

To find all hardlinks to file.txt, you can use

find -inum "$(stat -c %i file.txt)"

with or without the -maxdepth switch.


share|improve this answer
I'd add -xdev, for completeness in the general case. By definition, hard links will be on the same file system. (Though in this particular case, home dirs are very unlikely to span filesystems). – Rich Homolka Mar 27 '13 at 14:25

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.