hard links

Bill Campbell linux-sxs at celestial.com
Sat Oct 27 23:16:06 PDT 2007


On Sat, Oct 27, 2007, Ronnie Gauthier wrote:
>On Sat, 27 Oct 2007 21:39:10 -0600
>"Collins Richey" <crichey at gmail.com> wrote:
>
>> Thought for the weekend.
>> 
>> What is the purpose of a hard link, and does anything in Linux land
>> use hard links?
>>
>
>I guess the diff would be that when the last hard link is removed 
>the space is free. With a soft(symbolic) link when the symbolic link is 
>removed the linked to object still remains. I use sym_links all the time 
>but do not recall ever using a hard link but I guess a good example of 
>a sym_link is public_html and the www=>public_html folder. Many old 
>scripts used www hard coded in so the www sym_link is fairly standard
>when a linux account is created. If the user cluelessly deletes the 
>www sym_link they dont also blow away the entire website as would happen
>if it was a hard link. Guess thats sorta a backwards answer. But then 
>I probably dont correctly understand the full uses of the ln command.

Hard links are essentially multiple directory entries to a single
file while symlinks are aliases.  With hard links, the file isn't
removed until the last hard link is removed.  Symbolic links are
useful as they point to a file, directory, or anything else that
can be a directory entry, and continue to exist even when the
target is removed and be useful when the a new target is created.

Another major differences is that hard links only work for files,
not directories, and that are within a single file system while
symlinks can point to anything that can be in a directory and are
not restricted to a single file system.

Bill
--
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders, give
orders, cooperate, act alone, solve equations, analyze a new problem, pitch
manure, program a computer, cook a tasty meal, fight efficiently, die
gallantly.  Specialization is for insects. Robert Heinlein



More information about the Linux-users mailing list