I can't seem to find a way to do this, so maybe it's not actually possible, but I was wondering if there was a way to list all files that link to a file.

For example.

touch a
ln a b
ln a c

I want to find out what files link to a (not symlinks, mind you), assuming that this is more complicated (they are spread around to different directories).

I kind of understand about the filesystem storing links in one area and data in another, so I understand it probably takes more work to find a link from a file location than the other way around.

If I missed another question asking the same thing, let me know.


Try find / -samefile /file/to/compare.

There were a similar question: Finding all symbolic and hard links to a file on UNIX

  • Ah, ok. I guess I just wasn't searching for the correct thing. Thanks! – bradlis7 Jan 21 '10 at 22:50
  • This only works with GNU Find. – Ollie Saunders Jun 7 '10 at 13:00
  • I found no convenient options to do this in BSD Find, but you could try getting an inode number with ls -i and then doing find /mountpoint -x -inum $INODE. Inode represents contents of the file and not the filename. – whitequark Jun 7 '10 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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