Table of Contents
This practical guide walks through how to find broken symlinks in Linux, explains the main requirements, and highlights common issues that may appear along the way.
Tools to repair broken symlinks
There is a very useful application called simply symlinks in most app stores. This is a simple command line utility that will provide useful output and options for removing those broken symlinks.
To install it, use the following commands:
# For Debian / Ubuntu-based distributions:
sudo apt install symlinks
# For Fedora / CentOS:
sudo dnf install symlinks
There are several main options for symlinks. That is -d , will remove dangling links, and -r , will perform any options you specify through subfolders.
You can also use the find tool built into Linux. This is a less user-friendly example, but will be helpful if you learn the find command and how it works.
Break down symlinks
First, we will create a symlink. This involves retrieving an existing file and using the ln command to associate that file with a file that doesn't exist. That should look like the following example.
touch test-file.txt ln -s test-file.txt linked-file.txt
You can see from the ls command that the link exists.

Now, the post will break that symlink.
rm test-file.txt
You can see that even though the original file has been deleted, the ls -l command still reports the link. This is the cause of the problem. These files can be in different folders, which causes checking if the original file is still there.

Find and fix broken symlinks
The way to fix broken symlinks is to simply delete them. Damaged symlinks cannot be restored, so simply delete them from the virtual directory tree.
To report broken symlinks using the symlinks tool use the following command:
symlinks .
Note the '.' indicates the current working directory. Change this for whatever folder you're trying to find. The output might look like this:
dangling: /home/jperkins/linked-file.txt -> test-file.txt
Indicates that 'linked-file.txt' is hanging and that the symlink is down. To remove them, use the following command:
symlinks -d .
The output will look the same as last time but include a line for "deleted".

To fix broken symlinks with find , use the following command:
find . -xtype l

Note again that the '.' represents the current working directory. This will produce a less user-friendly but still useful output.
And to remove, add a delete option .
find . -xtype l -delete

You won't get any output for this command, but if you run it again without the -delete option , you won't see the symlink broken error anymore.
Key Takeaways
Use the information above as a practical reference for how to find broken symlinks in Linux. Review each step carefully, confirm any requirements, and choose the option that best fits your situation.
FAQ
What does this guide explain about Find Broken Symlinks in Linux?
It explains the main concepts, practical considerations, and useful steps related to find broken symlinks in Linux without requiring advanced knowledge.
Who can benefit from learning about Find Broken Symlinks in Linux?
This information is useful for readers who want a clear overview, practical guidance, and reliable steps related to find broken symlinks in Linux.
What should I check before applying this information?
Review the requirements, confirm that your device, software, or situation matches the instructions, and back up important data before making major changes.
Reader Comments 0
Sign in with email or Google to join the discussion.