Recursively finding symbolic links
by tgutwin
Posted on Tuesday Mar 18, 2025 at 04:02PM in Linux
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. (http://www.grymoire.com/Unix/Find.html)
Tags: linux