What's the difference between a relative & absolute Link?

Booting, installing, newbie
Post Reply
Message
Author
ssreddy
Posts: 41
Joined: Wed 12 Jun 2013, 16:39
Location: Hyderabad, India

What's the difference between a relative & absolute Link?

#1 Post by ssreddy »

Sorry for bothering u about this basic question.

What's the difference between a relative & absolute Link?

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#2 Post by Semme »

Relative links are essentially shortcuts. Does this page clarify it for you?

ssreddy
Posts: 41
Joined: Wed 12 Jun 2013, 16:39
Location: Hyderabad, India

#3 Post by ssreddy »

Semme wrote:Relative links are essentially shortcuts. Does this page clarify it for you?
Yes, sir.

This makes things abundantly clear.

Thanks a lot.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#4 Post by Semme »

Good. Now let's wrap up Osmo.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#5 Post by amigo »

Sorry, but that page is simply wrong. There are four terms that are used:
hard link
symbolic link (sometimes called soft)
relative link (actually relative path)
absolute link (actually absolute path)

hard links are hardly ever used and you must understand a bit about filesystems to know about them. symbolic links are created using the '-s' option to the 'ln' tool. When you use 'rm' on a symbolic link, the link is removed and not the object it points to.

relative and absolute refer to the *path* to the linked (real) object.
An absolute path always begins with '/' and fully describes the path to the object as viewed from the root of the filesystem '/'. A relative path describes the location of the object from the perspective of the 'current working directory'.

A relative link either starts with no '/', or starts with either './' or '../filename' (where there can any number of ../ or similar constructs)

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#6 Post by Burn_IT »

Just to confirm, Amigo is perfectly correct.
"Just think of it as leaving early to avoid the rush" - T Pratchett

User avatar
DaveS
Posts: 3685
Joined: Thu 09 Oct 2008, 16:01
Location: UK

#7 Post by DaveS »

I often wondered why there should be two options. I understand what they are, but not why they exist......
Spup Frugal HD and USB
Root forever!

ssreddy
Posts: 41
Joined: Wed 12 Jun 2013, 16:39
Location: Hyderabad, India

#8 Post by ssreddy »

DaveS wrote:I often wondered why there should be two options. I understand what they are, but not why they exist......
Yes, indeed!

Why not show the entire path always to make things clear?

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#9 Post by Burn_IT »

For the reason you may not know the full path when you start to search.

Then having displayed the files at a particular level you would be extremely cross if you had to keep on typing all the lower levels.
"Just think of it as leaving early to avoid the rush" - T Pratchett

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#10 Post by nooby »

When I drag the .mozilla over to /mnt/home/ on some puppies
that location has the name /dev-save/sda1/ or some similar to me
unusual name. I think I make them absoiute just in case it is needed
would it be better to always make them relative? I feel so lost so I ask you guys
I use Google Search on Puppy Forum
not an ideal solution though

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#11 Post by Burn_IT »

I believe that in the case you just mentioned the locations are exactly the same, but have been referred to by different names.

/mnt/home is a logical name within Puppy that translates to the physical location /dev-save/sda1/.



Do you say that you are going home, or do you say I you are going to No 6. Parkfield Road, Anytown. This Country. (If that is where you lived)
"Just think of it as leaving early to avoid the rush" - T Pratchett

nooby
Posts: 10369
Joined: Sun 29 Jun 2008, 19:05
Location: SwedenEurope

#12 Post by nooby »

I don't remember which puppy but one or two of them
rename /mnt/home7 that way. It is not me doing it :)

Should I prefer the Absolute or the Relative at such times?
I use Google Search on Puppy Forum
not an ideal solution though

ssreddy
Posts: 41
Joined: Wed 12 Jun 2013, 16:39
Location: Hyderabad, India

#13 Post by ssreddy »

Burn_IT wrote:I believe that in the case you just mentioned the locations are exactly the same, but have been referred to by different names.

/mnt/home is a logical name within Puppy that translates to the physical location /dev-save/sda1/.



Do you say that you are going home, or do you say I you are going to No 6. Parkfield Road, Anytown. This Country. (If that is where you lived)
If we want to make a relative path for /mnt/home, can we write it as
./home? Like wise, for /mnt/home/x1/x2, will the relative path be
.../x2?

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#14 Post by Burn_IT »

Introducing the dots into the location confuses the situation somewhat and can be confusing if you are not fully aware of how they work.

I've just tried looking up the rules and the best I could find is a Windows example ,but it is the same in Puppy:

Code: Select all

Dots and dot-dots

There are two special folder names that you can use in relative paths:

One dot (.) always refers to the current folder.
Two dots (..) refers to the folder that is one level higher than the current folder.

For example:

    The relative path to a program named foo.exe in a folder two levels above the current folder is:
    ..\..\foo.exe

    The relative path to a folder named Images in a folder three levels above the current folder is:
    ..\..\..\Images

    The relative path to a file named whatsup.doc in the current folder can either be written as:
    whatsup.doc

    or as:
    .\whatsup.doc
"Just think of it as leaving early to avoid the rush" - T Pratchett

ssreddy
Posts: 41
Joined: Wed 12 Jun 2013, 16:39
Location: Hyderabad, India

#15 Post by ssreddy »

Thanks.

But, in such a case, how to know what are the higher level folders just from dots? In other words, without knowing the hierarchy, how to know where the file is located from the path? (of course, there are other ways to find it).

I notice, In windows, they use absolute paths more often than not, don't they?

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#16 Post by Burn_IT »

I notice, In windows, they use absolute paths more often than not, don't they?
It very much depends on the circumstances.
I always use absolute paths on my own machine because I know the file name structure. If you are writing scripts for other people to use then it is far better to use relative paths because you have no idea where the script is being run from.
"Just think of it as leaving early to avoid the rush" - T Pratchett

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#17 Post by amigo »

"use relative paths because you have no idea where the script is being run from" This is exactly backwards. Use relative links when you *do* know the files layout and you know where the link is gonna be -or when it does not matter.

Usually, one will use both types according to the situation. An example of where relative paths are useful is with AppDirs, bundles, apps or application Directories -where everything (extra) an application needs is located under a single directory. The concept usually includes the fact that the app can be placed anywhere on your system -so-called 'run-from-anywhere'. Here any links which refer to objects under the AppDir should use relative paths. Any links to system objects should use absolute paths -although most scripts let the users' PATH be searched for any system binaries. A relative link may begin with '../', './' or with just a file or directory path *as seen from the directory where the link is located*.

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#18 Post by Burn_IT »

What about the people who install programs to other than the default C:\Program Files\ in Windows or move their Documents and Settings (as I do).
"Just think of it as leaving early to avoid the rush" - T Pratchett

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#19 Post by amigo »

Are we talking about Windows links or linux links?

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#20 Post by Burn_IT »

Doesn't matter.They both follow the same format.
"Just think of it as leaving early to avoid the rush" - T Pratchett

Post Reply