Linux: Find all symlinks of a given 'original' file? (reverse 'readlink')
I've not seen a command for this and it's not an easy task, since the target file contains zero information on what source files point to it.
This is similar to "hard" links but at least those are always on the same file system so you can do a find -inode
to list them. Soft links are more problematic since they can cross file systems.
I think what you're going to have to do is basically perform an ls -al
on every file in your entire hierarchy and use grep
to search for -> /path/to/target/file
.
For example, here's one I ran on my system (formatted for readability - those last two lines are actually on one line in the real output):
pax$ find / -exec ls -ald {} ';' 2>/dev/null | grep '\-> /usr/share/applications'lrwxrwxrwx 1 pax pax 23 2010-06-12 14:56 /home/pax/applications_usr_share -> /usr/share/applications