How to see full symlink path

15412s picture 15412s · Apr 15, 2013 · Viewed 221.7k times · Source

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?

Answer

Ian Stapleton Cordasco picture Ian Stapleton Cordasco · Apr 15, 2013

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"))'