This is merely just a vocabulary question, but which keeps turning around in my head.
It comes from a practice exam from a LPIC preparation book. The correct answer according to the book is that ~/Documents
is a relative directory because it is relative to the home directory.
However, this book contains an honourable ratio of typos and mistakes so I cannot take for granted everything which is written there. Here I do not agree because for me ~
acts as a variable expanded by the shell into either the content of the $HOME
variable or the current user home directory path (cf. man bash
), so the actual path is /home/myuser/Documents
which is indeed an absolute directory.
Even Wikipedia, for once, seems of no help to me on this topic (even if it seems to confirm that the book is wrong on this one):
An absolute or full path points to the same location in a file system regardless of the current working directory. To do that, it must contain the root directory.
By contrast, a relative path starts from some given working directory, avoiding the need to provide the full absolute path.
Here again, I do not agree: according to this definition, the path /opt/kde3/bin/../lib
which does not depends of the current working directory should be an absolute one, however my current understanding of this matches the book's author making this path a relative one.
A quick web-search is just adding to my frustration, according to Webster Dictionary:
absolute path - A path relative to the root directory. Its first character must be the pathname separator.
So $HOME/Documents
, or even just $HOME
would not be considered absolute directories? Or does this definition implies variable expansion? What about the shell's ~
character? Is there any reliable definition of relative vs. absolute directory I can find somewhere and am I wrong all of the way?
/
, and those we call absolute. Thus everything what starts from/
I would call absolute (even if this is/usr/../etc
) and everything else I would call relative (~/Doc
,Doc
,../john/Doc
,$HOME/...
,...). The point is that absolute should work regardless of current working directory or current user. Relative can work only in some specific narrow cases.~/foo
a relative path. What you're getting at is the difference between hard-coding and parameterization. See my answer for more details.~/Documents
and$HOME/Documents
are not paths. They do identify (absolute) paths after expansion, but they are not paths themselves. I think that agrees with how many Unix/Linux users use the term, but no doubt those strings are also called paths themselves.