The Broken Shortcuts
In Ubuntu Linux, a “symbolic link” (or symlink) is the equivalent of a Windows desktop shortcut. It is a tiny file that simply points to another file or directory located elsewhere on the server. Symlinks are heavily used by web servers (like Nginx) to enable and disable site configurations without moving the actual configuration files. However, if an administrator deletes the original target file, the symlink remains behind, completely broken and pointing to nothing. If you need to audit your server for these dead shortcuts or simply map out how your directories are linked together, you must instruct the Linux engine to filter out actual files and only return the symlinks.
Using the find Command with -type l
The Linux find command utilizes the -type l flag (a lowercase L) to instantly isolate symbolic links.
- Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
- To scan the
/etc/nginx/directory and explicitly return only the symlinks (ignoring the actual text configuration files), type the following command exactly: sudo find /etc/nginx/ -type l- Press Enter and provide your administrator password.
Identifying Dead Links
Once you have a list of symlinks, you can use a powerful command extension to find the “broken” ones. By running sudo find /etc/nginx/ -xtype l, the search engine will specifically look for symlinks that point to a file path that no longer exists. This is an essential command for cleaning up a messy web server and ensuring that your operating system isn’t trying to load configuration data from a ghost directory.