TCarrigan
Flight Engineer
Flight Engineer
  • 339 Views

What are the differences between absolute and relative paths?

Learn how absolute and relative paths compare and when to use each one. https://red.ht/3QYSiUn

0 Kudos
3 Replies
Trevor
Starfighter Starfighter
Starfighter
  • 313 Views

If a pathname begins with a forward slash, it's an ABSOLUTE pathname.  If it doesn't begin with a forward slash, guess what, it's a RELATIVE pathname.

Examples:

/tmp/one/two/three       ->  ABSOLUTE pathname

one         ->   RELATIVE pathname

../one       ->  RELATIVE pathname

../../one    ->   RELATIVE pathname


In the case of my RELATIVE pathname examples, you see that I'm showing multiple examples, which by the way all make reference to the same destination - the directory named "one".  The takeaway is, there can be several/many relative pathnames that refer to the same destination (filename or directory).  However, there will be, can be, ONLY ONE absolute pathname to any destination (filename or directory).

This wasn't the orginal question, but how do you identify a relative vs an absolute pathname?  If the first character in the pathname is a forward slash, the pathname is an ABSOLUTE pathname!!!!  End of discussion

Hope this helps (is that what HTH means)

 

Trevor "Red Hat Evangelist" Chandler
TCarrigan
Flight Engineer
Flight Engineer
  • 239 Views

This is a wonderfully easy to follow explaination of the concept! Thanks @Trevor 

Also, let me know if you might be interested in doing technical blogging, I think based on the above answer, that you would be great at writing 'to the point' technical content. You can find more information about our publication here: www.redhat.com/sysadmin

Trevor
Starfighter Starfighter
Starfighter
  • 211 Views

Hello TCarrigan, 

I'm humbled by your comment, along with your confidence that I might be great at writing, as you put it, "to the point" technical content.  I would certainly welcome that opportunity, and will absolutely investigate the possibility.  I love explaining things, and I know that the more I engage, the more I maintain and/or advance my own knowledge.
It's always been a win-win proposition for me!

Many thanks for making me aware of another avenue that will afford me the privilege
of being a contributor to the community.

 

 

Trevor "Red Hat Evangelist" Chandler
0 Kudos
Join the discussion
You must log in to join this conversation.