[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Sym Links: A Question



On 31 Mar 1999, in message <19990330145039 D6095 cisco com>
  Rob Napier <rnapier employees org> wrote:
| > What's the difference between a soft and a hard link? :)
[... description deleted ...]
| The point is that directory entries are just pointers to files. Hard
| links make two directory entries point to the same file. Symbolic
| links make one directory entry point to another one.
| 
| In a normal users life, you will generally only use symbolic links.
| Hard links are hard to track and can be very confusing. Of course
| symbolic links can also be very confusing, but they're too useful not
| to use anyway.

Argh. I see this advice everywhere. It Is Bad.

There are times and places for both types of link, but in general symlinks
are overused.

Hard links provide robustness against forgetting which end of the link
you're blowing away ("whoops, blew away the real thing - doh!") since
with a hard link there is no "real thing". They have other advantages
too.

Symlinks are not robust against directory restructuring; move the target and
all the links are now broken. Likewise, move the symlink and if it's a
relative link it is probably now broken too.

Symlinks are slower - every open() call must fetch the link, then fetch
the target.

Symlinks are marginally harder to set up - you must remember that the
link text is relative to the location

The list goes on.

The rule of thumb is: if a hard link does the trick, use it.
If a symlink serves some extra useful purpose, _then_ use a symlink.

Example: referencing a file on a different filesystem.
Example: documenting what version of a program is installed:

    % cd /usr/local/bin
    % ls -ld perl*
    lrwxrwxrwx   1 root     other          4 Jan 19 11:32 perl -> perl5.00464
    lrwxrwxrwx   1 root     other          4 Jan 19 11:32 perl5 -> perl
    -rwxr-xr-x   1 root     geeks     786524 Oct 19 18:35 perl5.00464

But use them sparingly, with a clear reason in your head for doing so.
They are definitely higher maintenance than hardlinks.
--
Cameron Simpson, DoD#743        cs zip com au    http://www.zip.com.au/~cs/

If he's not one thing, he's another.	- Buckaroo Banzai



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]