Skip to main content
Tips

Find All Symbolic Links in Linux

Looking for all the soft links on your Linux system? Here are a couple of methods to find symbolic links.

β€” Sagar Sharma

Warp Terminal

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:

use the tree command to find symbolic links

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.

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 Links directory:

find Links/ -type l
find symbolic links using the find command

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 -maxdepth flag.

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
search symbolic links to certain depth in linux

And if you want detailed output including the file permissions, user groups, etc. then you will have to pair the find command with -ls flag:

find Target_directory -type l -ls
get additional information of symbolic links using the find command

If you want a system-wide search, you can use / in the command.

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
use symlinks command to find all symbolic links in linux

Here, the -v option gives verbose output.

But by default, the symlinks utility won't look into subdirectories. Enable recursive search with the -r option:

symlinks -vr target_directory
use symlinks command recursively

The output has specific terms. Let me explain them.

  • relative indicates that links are relative to the current working directory in which the link resides.
  • other_fs means the link is indicating a different filesystem. In my case, it is indicated to the external drive.

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:

How to Create Symbolic Links in Linux [Complete Guide]
This detailed tutorial tells you what are symbolic links, how to create a symbolic links and other important things associated with symlinks.

And if you want to follow them to their origin, you can refer the following guide:

How to Follow Symbolic Links in Linux
You got a symbolic link and wondering about the actual source file? Here’s how to follow symlinks in Linux.

I hope you will find this guide helpful. And if you have any queries or suggestions, be my guest in the comments section.

Sagar Sharma