Sym Files

Thomas Stivers stivers_t at tomass.dyndns.org
Tue Oct 14 17:18:30 EDT 2003


On 10/14/03  4:42 PM -0400, Chuck Hallenbeck wrote:
> Luke,
> 
> While you are at it, what exactly is the difference between a
> hard link and a soft link?

The difference is that a symbolic (soft) link is a special file which
contains the name of the file it points to. Symbolic links can work
across file systems which hard links cannot.

Hard links are simply references to the same inode by another name, but
in every way besides the name they *are* the same file. Here is a sample "ls -l" that illustrates this.

total 0
-rw-r--r--    2 thomas   thomas          0 2003-10-14 16:00 file1
-rw-r--r--    2 thomas   thomas          0 2003-10-14 16:00 hard1
lrwxrwxrwx    1 thomas   thomas          5 2003-10-14 16:00 sym1 -> file1

In this example file1 is a regular file and hard1 is a link to it. The
number 2 after the file permissions means that the file has two names
linked to it and if we "rm" either file1 or hard1 that number will
decrease to 1. A key point is that they are both references to the same
file. The third entry sym1 is a symbolic link and is a different file
altogether, but it contains the name of file1 and because the file
system knows it is a link it will look for file1. I hope this doesn't
muddy the waters too much and Luke's description is still more
practical.

-- 
Unix is a user friendly operating system. It just picks its friends more
carefully than others.
Thomas Stivers	e-mail: stivers_t at tomass.dyndns.org	gpg: 45CBBABD




More information about the Speakup mailing list