[colug-432] Links
Rick Hornsby
richardjhornsby at gmail.com
Sun Feb 3 15:21:58 EST 2013
On Feb 3, 2013, at 12:07 , Steve VanSlyck <s.vanslyck at spamcop.net> wrote:
> Can I cut and paste symlinks from a directory to one its subdurectories and they will still work?
>
That depends on how the symlink was constructed, and if your window manager understands how to deal with symlinks. Most do, but I'm not sure if any of them will rewrite the link if you try to move it. Most of my Linux work over the last few years has been focused on the server side with no window managers in sight, so I'm not sure what progress or changes may have come about.
To the symlinks themselves:
Moving a relative link, foo to bar aka foo -> bar, would not work unless you moved both foo and bar to the same place. That construction is fairly common, and expects the files to stay in the same directory.
Moving an absolute link, foo to /usr/local/lib/bar should work fine. However, relative links can get more complicated than that, ie foo -> ../../bar would break if you moved foo, because you've changed the context that foo lives in, to where it is going up two directories looking for bar, when it should be (for example) three.
I would recommend that instead of futzing with the window manager, if you want to move a symlink, do it from a shell by removing the old symlink and creating the new one.
If you have a symlink /path/to/my_cool_app -> /home/steveo/projects/my_cool_app, you'd want to
rm -i /path/to/my_cool_app; ln -s /home/steveo/projects/my_cool_app /path/to/new/symlink
(I always have to remind myself that a symlink is target, link.)
Check out the man page for ln(1).
> Just like with windows?
>
Windows has no concept of symlinks*, which has over the years caused me no end of headaches. Windows has shortcuts, which are an entirely different thing and a poor excuse for something useful. Shortcuts are actual files that contain the metadata needed to locate the target, usually using an absolute path. That's why it seems that moving them around works without any problems. Most of the time I found that the only thing which could understand shortcuts was Windows itself. Very few applications could follow the shortcut to the target.
However, if you've ever tried to use a shortcut from the command line, you can't. Because it isn't a symlink. It is simply a .lnk file that the Microsoft Windows window manager (Explorer) knows how to deal with.
A symlink is fundamentally built into the various *nix filesystems, and to most applications, indistinguishable from the target file/directory unless said app is checking to see if what they're looking at is a symlink.
-rick
* That's not 100% true. At some point, Microsoft introduced the concept of file "junctions" into NTFS which were a half-assed attempt to imitate the behavior of symlinks. From what I remember, it was poorly documented, hardly anyone knew they existed (not well published), and they only worked from the command line though I could be wrong about that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20130203/bb14e8a3/attachment.html
More information about the colug-432
mailing list