LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Question related to hard link. (https://www.linuxquestions.org/questions/linux-newbie-8/question-related-to-hard-link-699785/)

saagar 01-25-2009 11:09 AM

Question related to hard link.
 
Friends,
I have a question related to hard link. I can understand the difference between soft link and hard link. But I wish to know what is the advantage of hard link. In the resources I have, it is mentioned that soft link is more advantageous since it is easy to change files and we can put a soft link to those files, also it is easy to identify an original file and its soft link ,but it is not possible to identify a hard link to an original file unless we know the inode numbers of the 2 files are the same.
With these disadvantages, why we are using hard link? Is it because it is useful in the programing side?
Also please let me know, what does it mean that "Hard link cannot be made to a different file system, but soft link can be made to a different file system"
Thanks.

Tinkster 01-25-2009 11:16 AM

Well .... the advantage of a hard-link is that as long
as at least one link exists, the file is physically there.

With a soft link, if you delete the original, the soft
link points into the void.

As for the question regarding "different file system":
If your hdd is partitioned, and e.g. parts reside on / (e.g.
sda1 and others on /usr (e.g. sda6), you can't make a hard
link from something on / to /usr, or vice versa.



Cheers,
Tink

pixellany 01-25-2009 11:21 AM

I don't use hard links, so I can only guess why they would be needed. Try this: "Any time that you need two references to the same data, such that either one can be deleted without losing the data."

Quote:

Also please let me know, what does it mean that "Hard link cannot be made to a different file system, but soft link can be made to a different file system"
Again....only guessing. I would assume for the same reason that you cannot create a filename on one filesystem that points to an inode on another.

Another way to look at it:
A hard link is another name for the same data
A soft link is a pointer to the data

servat78 01-25-2009 07:19 PM

You can set up hard links to an executable for several users in their home directories. If one of the users doesn't want to have that executable in the home directory, he/she can delete it. The other links are not affected, the executable till does exist, and it only takes disk space of a single copy.
Some users do not like softlinks to locations they do not understand or references to applications in root-protected locations like /bin - they simply feel they have to own the application by having in their own directory tree. It's also better as having hundreds of copies of the same executables, eating up disk space for the same thing. It is a preferred link type when maintaining accounts for non-technical people.

Debian

saagar 01-25-2009 10:29 PM

Tinkster, pixellany,servat78, thanks for your time in replying to my question. Thanks a lot

palisetty_suman 02-22-2009 06:26 PM

Thanks
 
Thanks, i too got to know.


All times are GMT -5. The time now is 03:19 PM.