How to Find Symbolic Links Pointing to a Specific File in Ubuntu (find -lname)

The Missing Link

In Ubuntu Linux, symbolic links (symlinks) act as advanced shortcuts, pointing from one location in the file system directly to another. System administrators frequently use them to link configuration files (like linking a config from /etc/nginx/sites-available to /etc/nginx/sites-enabled). However, if you are planning to move, rename, or delete the original “target” file, you must first locate every single symlink on the server that points to it. If you fail to do this, those symlinks will instantly become “broken,” potentially causing critical system services to fail upon reboot. You must explicitly instruct the Linux search engine to trace the links backward.

Using the find Command with -lname

The Linux find command utilizes the highly specific -lname flag to search the file system based entirely on the destination text stored inside a symbolic link.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To scan the entire server to locate any symlink pointing to the exact target /var/www/html/index.php, type the following command exactly:
  3. find / -type l -lname "/var/www/html/index.php"
  4. Press Enter.

Reverse Dependency Mapping

By combining -type l (which filters only for links) with -lname, the search engine will recursively dig through all subdirectories and output the absolute path of every shortcut pointing to your target file. You can also use wildcards. For example, typing -lname "*.php" will locate every symlink on the server that points to any PHP file. This allows you to completely map your server’s dependency structure before making destructive changes to the master files.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.