This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Hard links vs symbolic links
by merlyn (Sage) on May 14, 2001 at 20:34 UTC
    All entries in the filesystem are "hard links". A hard link goes from a name to an "inode number". The "inode" contains information about the file's permissions, ownership, type, and location on disk if any.

    The link operator makes additional names that have the same inode number, so that they are really the same file, but with two (or more) different names. There's no "real" name; they are all equally valid. Only when you've removed the last name for an inode will the system consider removing the data. So the rm command, or the unlink operator, is removing a name, not an inode.

    The symlink operator creates an inode with a name "pointer". When you reference the inode, its contents are substituted for the name, and the name lookup continues. Thnk of the "see ____" entry in an index. Now, that name might not be reachable or still exist, in which case you'll get a file-not-found error. Or it might in turn have another symlink... you're allowed to hop some small number of times (like 8 or 16, if I recall, depending on the kernel).

    Because inode numbers are within a particular "device" (think: "drive partition"), you can't have a "hard link" from one "device" to another. But you can "symlink" anywhere you want. Also, to keep the nice orderly hierarchy of nested directories clean, only the superuser can "hard link" to a directory, but anyone can create a symlink to a directory.

    -- Randal L. Schwartz, Perl hacker

Re: Quiz for Newbie
by coreolyn (Parson) on May 14, 2001 at 21:10 UTC

    In more newbian terms a hardlink points directly to a file, a softlink points to where the file is located.

    As for your your second question if you delete a link you delete the link not the file it's linked to via either method.

    It should be noted though, if you create a hard link and you wish the delete the original file it will still remain under the linked filename. With a softlink, if you delete the original file the softlink will remain but point to nothing.

    coreolyn
Re: Quiz for Newbie (why you are at -22)
by social_mandog (Sexton) on Oct 29, 2001 at 08:41 UTC
    You may be wondering why your post right now has a reputation of -22

    At least 23 people (or robots) voted your post --. (I voted it ++, to see the rep).

    There are a few reasons why this may have happened.

    1. Your post has nothing to do with Perl
    2. You could have answered the question yourself by typing man -k link and then  man ln
    3. Your title is not descriptive. "file link question" might have been better.
    4. Your title included the word "newbie"

    It may not be obvious to you why these are bad things. Generally people are annoyed when posts show an a lack of effort by the poster. When the lack of effort verges on willfull ignorance, people get nasty.

    I hope this helps. For what it is worth, I (mandog) also once hit negative experience points. (though not as many)