How to Find Symlinks in Ubuntu (find -type l)

The Broken Shortcut Audit

In Ubuntu Linux, symbolic links (symlinks) are files that act as pointers to other files or directories, functioning similarly to Windows shortcuts. When a server undergoes a major software upgrade or directory migration, the original files are often moved or deleted, leaving behind hundreds of “broken” symlinks that point to nowhere. To audit a filesystem for these pointers, you cannot search by filename or extension. You must instruct the search engine to filter files based exclusively on their inode type.

Using the find Command with -type l

The Linux find command utilizes the -type l flag (lowercase L) to explicitly search the filesystem for symbolic links, ignoring all regular files and directories.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To scan the /etc/ directory and return an exact list of every single symlink, type the following command exactly:
  3. find /etc/ -type l
  4. Press Enter.

Symlink Forensics

The -type l flag acts as a strict structural filter. It completely bypasses standard text files (-type f) and directories (-type d). It will only return files that are mathematically identified as symlinks. This command is highly flexible; system administrators frequently pipe the output of this command into other utilities to automatically test if the link is broken (e.g., using -exec test ! -e {} \; -print), allowing for the rapid cleanup of orphaned pointers across massive filesystems.

Get the best tech tips delivered straight to your inbox.

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