ln command (hard and symbolic links)

Darrin Chandler dwchandler at stilyagin.com
Fri Nov 9 12:49:25 MST 2007


On Fri, Nov 09, 2007 at 11:38:17AM -0800, keith smith wrote:
> 
> Hi everyone,
> 
> I'm needing to share some files between two hosting accounts and am looking at creating a few symbolic links.
> 
> In reading the man page for ln it says it creates a hard link by default or I can use --symbolic to create a symbolic link.  
> 
> What is the difference between a hard link and a symbolic link and why would I want to use one over the other?
> 
> Thanks a bunch in advance for your help.

A hard link is another actual link in the filesystem. Even a normal file
has one hard link. Creating a second directory entry with a hard link to
an existing file references the same actual disk file. Delete either
file and the other remains. Change either file and both are changed.
Hard links must be on the same filesystem (which is probably true in
your case).

A symbolic link creates a special file that serves as a pointer to
another location. Delete the original and the symlink becomes invalid.
Normally any editing and whatnot happen on the original file. Some
programs have options to handle symlinks in a certain way.

They have many things in common, but they are different beasts. If it's
important that the "copies" stay if you remove the original virtual host
files, then use hard links. If you want it to be crystal clear that
these are copies of a master file, use symlinks.

If this is a common situation, perhaps you can just share a directory
between vhosts instead, and put all the common files in there.

-- 
Darrin Chandler            |  Phoenix BSD User Group  |  MetaBUG
dwchandler at stilyagin.com   |  http://phxbug.org/      |  http://metabug.org/
http://www.stilyagin.com/  |  Daemons in the Desert   |  Global BUG Federation


More information about the PLUG-discuss mailing list