The Missing Target
In Ubuntu Linux, a symbolic link (or symlink) is essentially a highly advanced shortcut. Instead of duplicating a massive 10GB database file, an administrator can simply create a tiny symlink in a different folder that points back to the original file. While incredibly efficient, they can become a management nightmare. If a careless user deletes the original target file, the symlink remains behind, pointing to absolutely nothing (a “broken” link). If you are attempting to clean up a messy web server or debug a script that keeps failing due to missing files, you must first isolate and identify all the symbolic links scattered across the filesystem.
Using the find Command with -type l
The Linux find command utilizes the -type l (Link) flag to ignore all standard text documents and directories, returning only symbolic shortcuts.
- Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
- To search the entire
/var/www/directory for every single symbolic link, type the following command exactly: sudo find /var/www/ -type l- Press Enter and provide your administrator password.
Analyzing the Links
The command will instantly output a list of file paths. However, this only tells you where the shortcuts are located, not where they point to. To see the actual target destination of each link, you can combine the command with ls -l using the execute flag:
sudo find /var/www/ -type l -exec ls -l {} \;
This powerful combination will list every symlink and display an arrow (->) pointing directly to the exact file path of its original target, allowing you to instantly verify if the link is still valid.