linux - [Solved-4 Solutions] How to see full symlink path ? - ubuntu - red hat - debian - linux server - linux pc



Linux - Problem:

How to see full symlink path ?

Linux - Solution 1:

  • realpath isn't available on all linux.
readlink -f symlinkName
click below button to copy the code. By Linux tutorial team
  • You can do the following if you have python 2.6 (or later) installed
python -c 'import os.path; print(os.path.realpath("symlinkName"))'
click below button to copy the code. By Linux tutorial team

Linux - Solution 2:

realpath <path to the symlink file>
click below button to copy the code. By Linux tutorial team

Linux - Solution 3:

  • use the '-f' flag to print the canonicalized version.
readlink -f /root/Public/myothertextfile.txt
click below button to copy the code. By Linux tutorial team
man readlink
...
   -f, --canonicalize
          canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist
click below button to copy the code. By Linux tutorial team

Linux - Solution 4:

ls -l /root/Public/myothertextfile.txt
click below button to copy the code. By Linux tutorial team
  • But readlink would be preferred for use in a script rather than parsing ls

Related Searches to - linux - linux tutorial - How to see full symlink path ?