« Back to File systems: Frequently Asked Questions

How to find symbolic links that point to a directory

How to find symbolic links that point to a directory?

Use the find command to find symbolic links and define that the destination type should be a directory.

find . -type l -xtype d

The find command has so many options, that it may be overwhelming to learn all it has to offer. Let’s have a look at this particular question.

The obvious way to find a symbolic link is define -typel. This will search and show all symbolic links. To find all symbolic links that point to a directory, use find with the -type l and combine it with the -xtyped options.

find . -type l -xtype d

To search in a specific directory, replace the dot with the directory to start.

Learn more about find

This article uses the find command to achieve its tasks. For this popular tool there is a cheat sheet available!

» Mastering the tool: find

find cheat sheet

Other questions related to Linux file systems

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    Feedback

    Small picture of Michael Boelen

    This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

    Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution!

    Mastodon icon