Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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 In reply to Hard links vs symbolic links
by merlyn
|
|