How to Find All Symbolic Links in a Directory in Ubuntu Linux

The Symlink Audit

In Ubuntu Linux, a symbolic link (or “symlink”) is essentially an advanced shortcut that points to another file or directory elsewhere on the system. System administrators rely heavily on symlinks to route traffic. For example, the /etc/nginx/sites-enabled/ folder is typically completely filled with symlinks pointing to the actual configuration files stored in sites-available. However, if an administrator accidentally deletes the original target file without deleting the shortcut, the symlink becomes “broken,” leading to mysterious 404 errors and application crashes. Before cleaning up a directory, you must be able to identify which files are actually hard files and which ones are simply symbolic links.

Using the find Command with -type l

The standard Linux find command includes a highly specific file-type flag designed exclusively for locating symbolic links.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. Determine the directory you want to audit. For this example, we will check the entire /etc/ configuration folder.
  3. Type the following command exactly as written:
  4. sudo find /etc/ -type l
  5. Press Enter and provide your administrator password.

Refining the Output with ls

The command above will generate a raw list of paths (e.g., /etc/localtime). However, this only tells you where the shortcut is located; it does not tell you where the shortcut is actually pointing. To reveal the hidden target destinations, you can pipe the search results directly into the ls -l command:

  1. sudo find /etc/ -type l -exec ls -l {} +

The terminal will now print a beautifully formatted table. Look for the arrow (->) on the far right side of each row. It will clearly display exactly how the symlink is resolving (e.g., /etc/localtime -> /usr/share/zoneinfo/America/New_York), allowing you to easily map your server’s routing architecture or identify broken shortcuts.

Get the best tech tips delivered straight to your inbox.

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