Links, Absolute/Relative?
Links, Absolute/Relative?
Could somebody explain the difference between relative and absolute linking please?
Spup Frugal HD and USB
Root forever!
Root forever!
Thanks for this Bruce. I now understand that the relative/absolute relates to the path stored in the link, not some additional property of the link. I have been experimenting with moving directories that grow such as .mozilla outside of the _save file and keeping the _save file small, with great success. I am using a complex set-up with 4.2smp with only a 256KB _save file.
BTW, Seamonkey 2 looks very promising...................
BTW, Seamonkey 2 looks very promising...................
Spup Frugal HD and USB
Root forever!
Root forever!
Just got this info from Dennis:
* Shot #1:
All files are in /usr/lib. Both links were made there.
* Shot #2:
Both links moved to /usr/local; target remains in /usr/lib.
Symbolic link is now broken.
(In this case, it must be in same directory as target.)
However, absolute link is OK.
It can be moved anywhere within that file system.
And it won't break, unless the target is moved.
*Shot #3:
Now all files moved to /usr/local.
Absolute link is broken because target was moved.
Symbolic link is not broken because, although it was moved, it's in
same directory as target...just like it was in the beginning.
(And of course, if target is deleted, both links will break.)
Then I did the following:An absolute link is *not* a symlink. Symlink is short for "symbolic link."
*nix supports hard (absolute) links and symbolic links.
Hard links are created bySymlinks are created byCode: Select all
ln <source> <target>
The *nix file system supports indirection. A directory entry does not point to a file; it points to an inode, a kernel-maintained data structure that contains info like the file's owner, group, dates and permissions...and pointers to the blocks the file occupies on disk. So you can have more than one directory entry pointing to the same inode. This lets you have the same file appear in more than one directory, or the same file appear under more than one name in the same directory.Code: Select all
ln -s <source> <target>
The vi editor is an early example of the latter usage. Vi is the full-screen \editor. Ex is a line editor. View is Vi in read-only mode, used as a viewer. All three appear in /usr/bin, and are hard links to the same executable. The program looks at which name it was called by, and assumes the appropriate personality.
*nix maintains a count of links to a file. Delete a file with multiple links, and you are deleting that link. The file itself is not removed till there is only one link to it, and you delete that.
A symlink is conceptually similar to a Windows shortcut. Instead of a hard link to a file, you have a pointer to the file. The OS follows the pointer.
The difference in terms of usage is that hard links cannot span file systems. Hard links can only be created within the same file system that the file you are linking to is on. Symbolic links *can* span file systems.
The issue that can affect symlinks is removing files. If you remove the underlying file a symlink points to, the symlink still exists, and will return a broken link error if accessed.
In general, you can use a symlink where you would use a hard link, but not vice versa because of the file system limitation on hard links.
* Shot #1:
All files are in /usr/lib. Both links were made there.
* Shot #2:
Both links moved to /usr/local; target remains in /usr/lib.
Symbolic link is now broken.
(In this case, it must be in same directory as target.)
However, absolute link is OK.
It can be moved anywhere within that file system.
And it won't break, unless the target is moved.
*Shot #3:
Now all files moved to /usr/local.
Absolute link is broken because target was moved.
Symbolic link is not broken because, although it was moved, it's in
same directory as target...just like it was in the beginning.
(And of course, if target is deleted, both links will break.)
- Attachments
-
- All-files-usr-lib.png
- (10.2 KiB) Downloaded 116 times
-
- Both-links-usr-local .png
- (11.16 KiB) Downloaded 106 times
-
- All-files-usr-local.png
- (12.41 KiB) Downloaded 112 times