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 Answer 1

  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, 2013 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. May 29, 2013 at 8:50
  • Thanks, I meant could you expand on the parentheses :-).
    – dubiousjim
    May 29, 2013 at 22:07
  • 1
    @dubiousjim You can ask the kernel directly: man 2 lstat (dev_t) May 29, 2013 at 22:27
  • Is there anything wrong with using df for that purpose.
    – babou
    May 30, 2013 at 20:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .