Date: Sat, 9 Sep 2000 08:16:24 +0200 From: Erik Trulsson <ertr1013@student.uu.se> To: Bentley Rhodes <bentley3@mediaone.net> Cc: freebsd-questions@freebsd.org Subject: Re: hard links vs soft links, plus... Message-ID: <20000909081624.A989@student.uu.se> In-Reply-To: <39B98C43.380F570B@mediaone.net>; from bentley3@mediaone.net on Fri, Sep 08, 2000 at 09:03:01PM -0400 References: <39B98C43.380F570B@mediaone.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Sep 08, 2000 at 09:03:01PM -0400, Bentley Rhodes wrote: [ snip some questions about stuff I don't know anything about ] > fourth: > > i know that say. ... > [ ln -s /usr/whatever ] > can be used to point to directories or files...and that > [ ln /usr/whatever/file(s) ] > has to be used specifically for files (right?)....so besides that (if > i'm right)...whats the difference in Linking? > does a HARD LINK mean that i have that file on my computer? instead of > another users computer or area? i guess i mean copying (cp ).....but > that would be redundant. > > i know SOFT links redirect to the area or file...and if i [ cd .. ] > from it , say as an FTP thing, someone could end up in my root > directory. so my theory is that if i make a hard link to a file...then > basically, i still save space because the file is only like what...a > couple of kilobytes, versus the real file? > > bottom line...can someone fess up whats the best? > A soft link is just a pointer to another file or directory. That is it just contains the name of another file that is the one that should actually used when someone tries to read or write from/to the softlink. This means that if you remove the real file the softlink will point to a nonexisting file. A hard link is another kind of beast. Actually under Unix *all* files are hardlinks. Under Unix a file consists of three parts: The actual contents of the file. (Obviuos isn't it. :-)) An inode which contains info about the file, like its size, owner, what disk blocks it is stored on, etc A directory entry which is a name and a pointer to the files inode. When you create a hard link you just create another directory entry which points to the same inode. This means that you cannot distinguish between a normal file and a hardlink to it since both are actually just hardlinks to the same inode. This also means that a harlink can only be made to a file that resides on the same disk since inodes are per disk. (While softlinks can span filesystems.) In both the case of a softlink and a hardlink the actual contents of the file will only be stored once on the disk. If you delete one hardlink any other hardlinks to the same file will remain just as they were. This also means that if you delete a hardlink and then create a new file with the same name then any other hardlinks to that file will still refer to the original file, while a softlink would get the new file. (Since it only uses the name of the file.) Usually I suggest you use softlinks unless you have some particular reason to use a hardlink. Softlinks are generally more flexible and you are less prone to surprises. -- <Insert your favourite quote here.> Erik Trulsson ertr1013@student.uu.se -- <Insert your favourite quote here.> Erik Trulsson ertr1013@student.uu.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000909081624.A989>