On Mon, 16 Dec 2002, Dylan wrote:
On Monday 16 December 2002 22:52, Anders Johansson wrote:
On Monday 16 December 2002 22.33, John Andersen wrote:
And thinking of a link as a file is NOT correct. Its just another pointer to a file, essentially another directory entry pointing to the file,
Not a symlink. A symlink has its own inode. A hard link is "just another directory entry" but a symlink is more. That's why you can have symlinks to files on other partitions but not hard links.
OK, so when 'should' we use a hardlink, and when 'should' we use a symlink?
For instance, if you want a shortcut to /var/log/messages, a hardlink would apparently cease to work when the logs are rotated, because suddenly your shortcut points to something like /var/log/messages-20021217.gz. This is because with a hardlink you are creating another reference to the same file, and this reference does not care if the original file gets renamed or moved or even deleted. If you want to point to a location (ie a filename) you should use a symlink. If you want to have the same file accessible for different users with different permissions, you have to use a hardlink. (If the file is a /dev/* entry, you could also just mknod with another name, because they only really care about the major/minor numbers and c or b type.) Symlinks can also point to items that don't exist in the filesystem. One example is the lock-file created by Mozilla, which is actually a symlink pointing to IPnumber:ProcessID. If you install a program in a non-standard location, it could be smart to put a symlink in one of the $PATH directories. If you used a hardlink, users would keep running the old version when you upgrade. So, to summarize: Unless you are trying to do something that requires a hardlink, just use symlinks. I hope this helped clear things up a bit. Regards Ole