LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   Difference Between Soft Link & Hard Link (https://www.linuxquestions.org/questions/solaris-opensolaris-20/difference-between-soft-link-and-hard-link-424007/)

rajaniyer123 03-12-2006 12:57 AM

Difference Between Soft Link & Hard Link
 
I would like to knoe the difference between SOFT LINK [Symbolic Link] & Hard link in solaris

aus9 03-12-2006 01:54 AM

do not use solaris but it should be the same as linux or unix

soft or symbolic is more of a short cut to the original file....if you delete the original the shortcut fails and if you only delete the short cut nothing happens to the original.

hard link is more of a mirror copy....do something to file1 and it appears in file 2
deleting one still keeps the other ok

jlliagre 03-12-2006 05:43 AM

aus9 explanation definitely applies to Solaris (a.k.a. Unix) too.

javier.e.menendez 03-12-2006 03:15 PM

2 more differences:

Hard links share the same inode. Soft links do not.
Hard links can't cross file systems. Soft links do.

john83reuben 02-02-2009 09:39 AM

Quote:

Originally Posted by javier.e.menendez (Post 2147109)
2 more differences:

Hard links share the same inode. Soft links do not.
Hard links can't cross file systems. Soft links do.

What does it mean when u say, hard links cant cross file system. Do you mean we can make hardlinks when the source file is in UNIX and destination file is in NTFS file system? (in a dual boot)?


John

Blinker_Fluid 02-02-2009 02:41 PM

Quote:

Originally Posted by john83reuben (Post 3429187)
What does it mean when u say, hard links cant cross file system. Do you mean we can make hardlinks when the source file is in UNIX and destination file is in NTFS file system? (in a dual boot)?


John

Hard links share the same inode (kind of like location on disk) which is confined to a certain file system. So your example of a source file on a unix partition and a destination file on a NTFS partition would need to be soft links.

kebabbert 02-03-2009 05:59 AM

On a hard disk there are lots of sectors.

Say a file starts at inode (sector) 4001 and ends at 5000. The file is "/export/home/john/mail.doc"

Then:
1. A hard link to "mail.doc" which is named "hardLinkToMail" contains the value: "4001".
2. A soft link to "mail.doc" which is named "softLinkToMail" contains the value: "/export/home/john/mail.doc".

In 1) the hard link can only point to the same disk. It can not point to another drive. All drives has an inode of value "4001", how can the hard link distinguish between all discs? Which drive's "4001" is it?

In 2) the soft link contains a string. The string can point to another filesystem on another drive, because the full path is specified

kebabbert 02-06-2009 01:31 PM

Is there something wrong with this forum? This thread has something like 9000 hits. The other threads has a couple of hundreds. 9000 hits sounds not plausible?

jlliagre 02-06-2009 04:09 PM

Nothing wrong with the forum. Here are a couple of reasons that can explain this popularity:
- This thread is three years old
- Its title is a very common question

kiranjith 04-01-2009 05:55 AM

http://www.linuxclues.com/articles/01.htm

simplest way that we can understand the difference

krmanishsharma 01-30-2012 10:52 PM

SOFT LINK [Symbolic Link] & Hard link
 
Hard link point to the file content
while Soft link points to the file name.
while size of hard link is the size of the content while soft link is having the file name size

gopa 09-28-2012 04:43 AM

Difference Between Hard Link and Soft Link
 
Hard Link:

While creating a link from source to Destination file. ----> The changes done in the source file will be effected in destination file.

But when The source file is deleted the destination file remains the same.


Soft Link:

While creating a link using soft link from source to destination file → the changes done in the source file will be effected in Destination file too.

But when the source file is deleted the destination file also gets invisible. i.e when u tried to check the destination file its says no such file or directory

Note: Its always best practice to give a hard link than soft link

Hard Link syntax: ln file1 file2

Soft link Syntax: ln -s file1 file2


Thanks & Regards,
Gopal Varma P

jlliagre 09-29-2012 03:08 AM

Quote:

Originally Posted by gopa (Post 4791409)
The changes done in the source file will be effected in destination file.

More precisely, there is a single file that is modified and it can be accessed by two different names.
Quote:

But when The source file is deleted the destination file remains the same.
Because you do not delete a file, you just delete a name.
Quote:

Its always best practice to give a hard link than soft link
Not necessarily. Symbolic links have some features hard links are missing.

gopa 09-29-2012 05:14 PM

@jlliagre: Thanks for your much detailed points on this. Would like to request for the features like which are missing in Hard Links.

Thanks in advance

Regards,
Gopal Varma P

jlliagre 09-29-2012 05:43 PM

Quote:

Originally Posted by gopa (Post 4792803)
Would like to request for the features like which are missing in Hard Links.

  • hard-links cannot cross file systems
  • you know immediately where a symbolic link points to while with hard links, you need to explore the whole file system to find files sharing the same inode.
  • hard-links cannot point to directories


All times are GMT -5. The time now is 08:15 AM.