Question:
what is relative path , and what is absolute path?
2013-10-20 03:08:19 UTC
in linux, what is relative path ,and what is absolute path?

can you give me an example? tnx!
Four answers:
2013-10-21 02:48:57 UTC
An absolute path is the full URL to a file. A relative path points to the location of the file you want to link to in relation to the page being viewed, all within your server space. If the page you're linking to is in the same directory as the page being viewed, then the relative path is simply the page name.



If you're linking to pages on your own site, using a relative path will make your site load quicker.



Absolute vs. Relative Paths/Links: http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/



Absolute and Relative Paths: http://webdesign.about.com/od/beginningtutorials/a/aa040502a.htm



Server Paths Explained: http://www.boogiejack.com/server_paths.html



Ron
?
2016-10-05 13:29:55 UTC
Relative Path
Neerp
2013-10-20 08:47:58 UTC
The example given to you by "just JR" as an absolute path is incorrect. An absolute path ALWAYS starts with /, which is the indicator of the root directory. Absolute paths ALWAYS start with /. A relative path does not start with /.



Also, he shows back slashes in his example. Linux does NOT recognize back slashes. The example he gives would not work for both of those reasons.



These are valid examples of absolute paths:



/opt

/usr/local/src

/home/joe



ALL of these start with /



These are examples of relative paths:



../home/Joe

./Music

Music



Notice that ./Music and Music both do the same thing. They look at the Music directory immediately below the current directory.



A single period means start right here in the current directory.



A double period means jump up a directory level. So, this:



../home/Joe



Would point to the directory Joe, which is under the directory home, which is directly above the current directory.
just "JR"
2013-10-20 03:46:06 UTC
Relative: call for a file FROM the CURRENT directory:

"myfile.xxx": in the SAME directory

"..\..\myfile.xxx": two directories above the current one

Absolute: "drive/folder/subfolder/file" (from the root)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...