On Thu, 25 Oct 2001, David Brown wrote:

> I have this up and running as well, except for the web monitoring, which I
> just found out existed.  That'll teach me to *really* RTFM. :)  I also
> botched the link in /etc/rc.d/rc7.d/S20apcupsd  This might be a question out
> of ignorance, but is this a symbolic link (ln -s) or a hard link, and what
> is the difference anyway?

It's a symbolic link.

I really dislike the terms "hard" and "soft" links. I don't find them
useful, and I think they obfuscate the facts.

A data file in linux is a set of disk blocks. The list of blocks is
contained in a disk structure known as an inode. To find the contents of a
file, you need three numbers - the major and minor device numbers, which
collectively identify which disk partition the file is on, and the inode
number. But that's not how you normally find files. Files are found via
path names, which comprise a directory name and a file name. A directory
is a special type of file. A directory contains a table of file names and
inode numbers. Each entry in the table is a link. In other words, a
directory entry is a link. Any file can have multiple links - in other
words, an inode can have multiple directory entries which point to it.

Here is an example when a file is created, then another link created, so
that there are two links (directory entries) which point to the same file
(inode).

[charlieb@vegemite tmp]$ ls
[charlieb@vegemite tmp]$ echo foo > afile
[charlieb@vegemite tmp]$ ls -l
total 4
-rw-rw-r--    1 charlieb charlieb        4 Oct 25 12:35 afile
[charlieb@vegemite tmp]$ ln afile anotherfile
[charlieb@vegemite tmp]$ ls -l
total 8
-rw-rw-r--    2 charlieb charlieb        4 Oct 25 12:35 afile
-rw-rw-r--    2 charlieb charlieb        4 Oct 25 12:35 anotherfile
[charlieb@vegemite tmp]$ ls -li
total 8
 736500 -rw-rw-r--    2 charlieb charlieb        4 Oct 25 12:35 afile
 736500 -rw-rw-r--    2 charlieb charlieb        4 Oct 25 12:35 anotherfile
[charlieb@vegemite tmp]$

Notice in the last step that both files have the same inode number. Note
also that the "link count" displayed in the directory entry is two.

Now let's consider a symbolic link.

[charlieb@vegemite tmp]$ ls -li
total 8
 736500 -rw-rw-r--    2 charlieb charlieb        4 Oct 25 12:35 afile
 736500 -rw-rw-r--    2 charlieb charlieb        4 Oct 25 12:35 anotherfile
 736501 lrwxrwxrwx    1 charlieb charlieb        5 Oct 25 12:37 symlink -> afile
[charlieb@vegemite tmp]$

You can see here that the symbolic link (symlink, so-called "soft" link)
has its own inode number. A symlink is a special type of file - one which
contains the *name* of another file (or directory). This special type of
file is interpreted automatically by the operating system, and the file or
directory pointed to is accessed when the symlink is accessed.

Here endeth the lesson...

-- 

Charlie Brady                         [EMAIL PROTECTED]
Lead Product Developer
Network Server Solutions Group        http://www.e-smith.com/
Mitel Networks Corporation            http://www.mitel.com/
Phone: +1 (613) 368 4376 or 564 8000  Fax: +1 (613) 564 7739



--
Please report bugs to [EMAIL PROTECTED]
Please mail [EMAIL PROTECTED] (only) to discuss security issues
Support for registered customers and partners to [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Archives by mail and http://www.mail-archive.com/devinfo%40lists.e-smith.org

Reply via email to