Search code examples
linuxsymlink

How to see full absolute path of a symlink


When I'm using ls -la symlinkName or stat symlinkName not all the path is displayed (e.g ../../../one/two/file.txt)

What is the linux command that reveals the full path?


Solution

  • realpath isn't available on all linux flavors, but readlink should be.

    readlink -f symlinkName
    

    The above should do the trick.

    Alternatively, if you don't have either of the above installed, you can do the following if you have python 2.6 (or later) installed

    python -c 'import os.path; print(os.path.realpath("symlinkName"))'