How do you find a soft link?
You can use the ls command. Some distributions show the links in a different color. The long listing is always reliable because it shows links with l.
lrwxrwxrwx 1 abhishek abhishek 14 Jan 31 18:07 my_link -> redirects.yaml
You can also use the tree command:
This is okay if you have a couple of links in the current directory. But what if you want to see the links in a nested directory structure or the entire system?
In this tutorial, I will be showing you two ways to accomplish this mission:
- Using the find command
- Using the symlinks utility
So let's start with the first one.
Use find command to look for symbolic links
To find the symbolic links using the find command, you can use the following command syntax:
find Target_directory -type l
For example, here, I searched for available symbolic links inside the
find Links/ -type l
But by default, the find command will initiate the recursive search and if you want to limit the search to a certain depth, you will have to use the
So let's say I want to restrict the search to level 1 for the
Links directory, I will be using the following:
find Links/ -maxdepth 1 -type l
And if you want detailed output including the file permissions, user groups, etc. then you will have to pair the find command with
find Target_directory -type l -ls
If you want a system-wide search, you can use
/ in the command.
Use the symlinks utility to find all symbolic links
This tool is what I used while pursuing my internship in networking.
But it does not come pre-installed though. You can install it using your distribution's package manager. For Ubuntu/Debian, use:
sudo apt install symlinks
Once you are done with the installation, use the given command structure to look for available symbolic links:
symlinks -v target_directory
-v option gives verbose output.
But by default, the symlinks utility won't look into subdirectories. Enable recursive search with the
symlinks -vr target_directory
The output has specific terms. Let me explain them.
relativeindicates that links are relative to the current working directory in which the link resides.
other_fsmeans the link is indicating a different filesystem. In my case, it is indicated to the external drive.
Symbolic Links are Easy!
Really, they might sound like a huge deal but we made sure to break the topic bit by bit.
Such as if you are a complete beginner, you can refer to the beginner's guide to symbolic links:
And if you want to follow them to their origin, you can refer the following guide:
I hope you will find this guide helpful. And if you have any queries or suggestions, be my guest in the comments section.
Join the conversation