How to find every symbolic link on a server?

10,955

Solution 1

You need to pass a top directory name. Some versions of find assume the current directory if you omit it, but not AIX's. Also, -L isn't what you want here: it tells find to follow symbolic links, but that's not what you're asking, you're asking to find symbolic links.

find / -type l -print will print out all the symbolic links.

See man find

Solution 2

If you want to know what the symbolic link points to, enter following command:

find / -type l -exec ls -l {} \;

Share:
10,955

Related videos on Youtube

Deckard
Author by

Deckard

Big fan of Deckard(or Baby Chaos)

Updated on September 18, 2022

Comments

  • Deckard
    Deckard almost 2 years

    I need to find every symbolic link on the server.

    The version is AIX 6.1.

    man find says

    -L Follow symbolic links
    

    But find -L is not a proper usage. Usage: find [-H | -L] Path-list [Expression-list]

    I tried to Google this but couldn't find answers.

    • Overmind Jiang
      Overmind Jiang over 12 years
      By default, if you use find /some/directory -name '*.txt', the find command will not follow any symbolic links it finds as it is traversing the sub-structure of the starting directory. If you add the -L option, it will follow symbolic links (and, in particular, if any of those links leads to a directory, it will traverse that remote directory). The reason why this is not the default behaviour is that it can lead to 'infinite' paths. Consider what happens when you have a symlink created by ln -s . xyz...without the -L, there'll be no problem; with it, find runs for a long time.