The issue of resolving symlinks (symbolic links) is often addressed on this forum, and on others. Related are the concepts of relative, absolute (or full), and canonical (or resolved) pathnames. Two now standard utilities are available, for example in GNU core utilities, to resolve symlinks, and, among other things, produce canonical pathnames: readlink and realpath.

Why do we need canonical paths?

Can you give examples where canonical paths are required, and non-canonical absolute paths will not be acceptable?

Side question: why do people get "canonical path" answers for "absolute path" questions? But is this technology or sociology ?

  1. You need canonical paths to determine the volume a file system object resides on (if you want to do it that way; there are other ways).
  2. If access rights refer to paths (like with Apache) then you need canonical paths.
  • Can you expand on #1? – dubiousjim May 29 '13 at 0:37
  • @dubiousjim /data/README.txt can be on a volume which is mounted on /home. You need to know whether it happens to be a link to e.g. /home/user/README.txt. – Hauke Laging May 29 '13 at 8:50
  • Thanks, I meant could you expand on the parentheses :-). – dubiousjim May 29 '13 at 22:07
  • 1
    @dubiousjim You can ask the kernel directly: man 2 lstat (dev_t) – Hauke Laging May 29 '13 at 22:27
  • Is there anything wrong with using df for that purpose. – babou May 30 '13 at 20:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.