Question about links (hard and sym) (Answered)
Question about links (hard and sym) (Answered)
So, in the terminal I can ln or ln -s
whats the difference and how do these relate to the 'relative' and 'absolute' options I get when dragging a file/directory from one rox window to another?
whats the difference and how do these relate to the 'relative' and 'absolute' options I get when dragging a file/directory from one rox window to another?
OK answered it myself. Took a bit of effort as most of the stuff out there is about html design but if anyone else is interested here is a good start.
http://www.linuxformat.co.uk/forums/vie ... hp?p=79553
http://www.linuxformat.co.uk/forums/vie ... hp?p=79553
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
A hard link points at a location on the harddrive. Every file is a hardlink. Basically, you can think of a hardlink as the name that points at the data.
Data on the harddrive "exists" as long as at least one name points at it. When there is only one name pointing at it and you delete that name, the file is considered deleted. (Actually the data is still there, but the area of the disk where it lives is now considered "free", so that when you try to write new data to the drive, it might overwrite the old "deleted" data.)
So, let's say I have a file named "bob". If I make a hardlink to bob that is named cindy, I will then have two names for the same data. They are indistinguishible. There is no way to determine which is the real one and which is the link - because they are both equally real. I can delete bob, and the data will still be there because cindy still points at it.
Symlinks (symbolic links) are different. A symlink is more like a "shortcut" from Windows (but generally better). Hard links point at data. Symlinks point at a filename. So if you have a file named "thomas" and you make a symlink to thomas named "rebecca", those are not identical. The "thomas" item points at the data. The "rebecca" item only points at thomas. If you delete thomas, rebecca will still be pointing at thomas, but since thomas isn't there, he can't point you to the data. Therefor the data is deleted, and rebecca is a broken link.
Since hard links point at actual data, they have to be on the same partition as the data they point at. Since symlinks only point at a filename, they can point at any filename on the system.
Data on the harddrive "exists" as long as at least one name points at it. When there is only one name pointing at it and you delete that name, the file is considered deleted. (Actually the data is still there, but the area of the disk where it lives is now considered "free", so that when you try to write new data to the drive, it might overwrite the old "deleted" data.)
So, let's say I have a file named "bob". If I make a hardlink to bob that is named cindy, I will then have two names for the same data. They are indistinguishible. There is no way to determine which is the real one and which is the link - because they are both equally real. I can delete bob, and the data will still be there because cindy still points at it.
Symlinks (symbolic links) are different. A symlink is more like a "shortcut" from Windows (but generally better). Hard links point at data. Symlinks point at a filename. So if you have a file named "thomas" and you make a symlink to thomas named "rebecca", those are not identical. The "thomas" item points at the data. The "rebecca" item only points at thomas. If you delete thomas, rebecca will still be pointing at thomas, but since thomas isn't there, he can't point you to the data. Therefor the data is deleted, and rebecca is a broken link.
Since hard links point at actual data, they have to be on the same partition as the data they point at. Since symlinks only point at a filename, they can point at any filename on the system.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
Ok, I think i have it but if someone could just confirm this for me.
in the terminal ln will create a hard link.
ln -s will create a symbolic link which can be either absolute or relative according to how the link name is written. A full path gives an absolute link and something else that I am not quite sure of gives a relative link. The absolute and relative links are those used by rox.
And if I want things to "just work" I should stick to absolute links when using rox.
Is that a reasonable stab at getting my head round this?
Thanks.
in the terminal ln will create a hard link.
ln -s will create a symbolic link which can be either absolute or relative according to how the link name is written. A full path gives an absolute link and something else that I am not quite sure of gives a relative link. The absolute and relative links are those used by rox.
And if I want things to "just work" I should stick to absolute links when using rox.
Is that a reasonable stab at getting my head round this?
Thanks.
I had thought I understood this but after reading this thread it appears may be not. Could someone please confirm?
My understanding of absolute and relative was as follows:
Absolute: path is stored relative to /
Relative: path is stored relative to target.
Relative link and target can be moved and the link will stay intact.
If absolute link and target are moved then the link will be broken.
My understanding of absolute and relative was as follows:
Absolute: path is stored relative to /
Relative: path is stored relative to target.
Relative link and target can be moved and the link will stay intact.
If absolute link and target are moved then the link will be broken.
- Sit Heel Speak
- Posts: 2595
- Joined: Fri 31 Mar 2006, 03:22
- Location: downwind
(deleted by poster, erroneous. See Pizzasgood's message, below)
Last edited by Sit Heel Speak on Mon 09 Nov 2009, 01:11, edited 1 time in total.
- Pizzasgood
- Posts: 6183
- Joined: Wed 04 May 2005, 20:28
- Location: Knoxville, TN, USA
No no no no no.
Absolute != hard.
A hard link is a hard link. There is no concept of absolute vs. relative for hard links. They don't involve filenames at all, they point at the data on the disk.
Only a symlink can be relative or absolute. Lapis had it right:
So, in summary:
Hard Link
Absolute != hard.
A hard link is a hard link. There is no concept of absolute vs. relative for hard links. They don't involve filenames at all, they point at the data on the disk.
Only a symlink can be relative or absolute. Lapis had it right:
Also, ROX-Filer will NOT let you create a hard link. You have to do that by hand.My understanding of absolute and relative was as follows:
Absolute: path is stored relative to /
Relative: path is stored relative to target.
So, in summary:
Hard Link
- Created with plain ln
Points at the actual data.
Can be moved and will point at the original data.
Must be on the same partition as the target data.
Is neither absolute nor relative - simply is.
Has no arrow emblem over the icon.
- Created with ln -s
Points at a filename, not at the actual data in question.
Uses an absolute path to the destination, starting from /
Can be moved and will point at the original target if that did not move.
Can point across partitions.
Has an arrow emblem over the icon.
- Created with ln -s
Points at a filename, not at the actual data in question.
Uses a relative path to the destination, starting from wherever it is located.
If moved, it will generally not point at the original item unless the original item was also moved so that the relative path between them stayed the same.
Can point across partitions.
Has an arrow emblem over the icon.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
[img]http://www.browserloadofcoolness.com/sig.png[/img]
- Sit Heel Speak
- Posts: 2595
- Joined: Fri 31 Mar 2006, 03:22
- Location: downwind
I stand corrected.
From ln --help:
Thus I inferred, erroneously, that hard==absolute.
From ln --help:
Code: Select all
-s, --symbolic make symbolic links instead of hard links
Thanks for this Pizzasgood.............. finally, a clear concise explanation of absolute/relative linking.Pizzasgood wrote:No no no no no.
Absolute != hard.
A hard link is a hard link. There is no concept of absolute vs. relative for hard links. They don't involve filenames at all, they point at the data on the disk.
Only a symlink can be relative or absolute. Lapis had it right:Also, ROX-Filer will NOT let you create a hard link. You have to do that by hand.My understanding of absolute and relative was as follows:
Absolute: path is stored relative to /
Relative: path is stored relative to target.
So, in summary:
Hard LinkAbsolute Symbolic Link
- Created with plain ln
Points at the actual data.
Can be moved and will point at the original data.
Must be on the same partition as the target data.
Is neither absolute nor relative - simply is.
Has no arrow emblem over the icon.Relative Symbolic Link
- Created with ln -s
Points at a filename, not at the actual data in question.
Uses an absolute path to the destination, starting from /
Can be moved and will point at the original target if that did not move.
Can point across partitions.
Has an arrow emblem over the icon.
- Created with ln -s
Points at a filename, not at the actual data in question.
Uses a relative path to the destination, starting from wherever it is located.
If moved, it will generally not point at the original item unless the original item was also moved so that the relative path between them stayed the same.
Can point across partitions.
Has an arrow emblem over the icon.
Spup Frugal HD and USB
Root forever!
Root forever!