Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a file system where one or more symlinks exist to a file. Is there a way to go thru each file and determine where all the symlinks that point to it on the file system are?

OS is Ubuntu 9.10 Linux

share|improve this question
    
Operating system? –  DaveParillo Apr 21 '10 at 3:55
    
linux - ubuntu 9.10 to be exact –  Roy Rico Apr 22 '10 at 15:41
add comment

1 Answer

up vote 3 down vote accepted

You can use good old find with the -lname switch:

find / -lname '/path/to/linked/file' 2> /dev/null

For a more intricate approach, you can use the inode number of the file (retrieve from ls -i <file>):

find / -follow -inum 123456 2> /dev/null
share|improve this answer
    
this has the limitation that it only matches a symlink with that exact filename (or pattern). it wouldn't catch a symlink to a symlink to that file. (so if symB points to fileA and symC points to symB, and you run this command looking for fileA, it'll find symB but not symC.) –  quack quixote Apr 21 '10 at 4:05
    
True, but I'm just following the criteria he's given us. –  John T Apr 21 '10 at 4:07
    
just sayin'. nice addition tho. :) –  quack quixote Apr 21 '10 at 4:19
add comment

Your Answer

 
discard

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.