Home‎ > ‎Tom's Ideas And Notes‎ > ‎

Recursively finding symbolic links

posted Jan 30, 2010, 10:58 AM by Tom Gutwin   [ updated Nov 12, 2011, 7:16 PM ]
Linux Command Prompt
Have you ever needed to find all the symbolic links you have created to a certain directory?

I recently wanted to move some partitions around on my drives and needed to see where I had mounted and linked to them before I moved them.

Here is a quick way to search for all the links.

find command

sudo find / -mount -type l  -print | sudo xargs ls -ld | awk '{print $10}' | grep /mnt/f11

It uses the find command and goes through the entire file system looking for the sym links then listing only the ones that point to the directory I am looking for (specified as the last parameter.  Note that the '-mount' option stays on the current file system.

Take a look at this good description & usage of find.