Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

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.

share|improve this question
up vote 3 down vote accepted

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

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

share|improve this answer
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .