LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 03-12-2006, 12:57 AM   #1
rajaniyer123
Member
 
Registered: Feb 2004
Location: BARODA, GUJARAT
Posts: 259

Rep: Reputation: 30
Difference Between Soft Link & Hard Link


I would like to knoe the difference between SOFT LINK [Symbolic Link] & Hard link in solaris
 
Old 03-12-2006, 01:54 AM   #2
aus9
LQ 5k Club
 
Registered: Oct 2003
Location: Western Australia
Distribution: Icewm
Posts: 5,842

Rep: Reputation: Disabled
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
 
1 members found this post helpful.
Old 03-12-2006, 05:43 AM   #3
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
aus9 explanation definitely applies to Solaris (a.k.a. Unix) too.
 
Old 03-12-2006, 03:15 PM   #4
javier.e.menendez
Member
 
Registered: Jan 2006
Posts: 168

Rep: Reputation: 30
2 more differences:

Hard links share the same inode. Soft links do not.
Hard links can't cross file systems. Soft links do.
 
Old 02-02-2009, 09:39 AM   #5
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Rep: Reputation: 17
Quote:
Originally Posted by javier.e.menendez View Post
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
 
Old 02-02-2009, 02:41 PM   #6
Blinker_Fluid
Member
 
Registered: Jul 2003
Location: Clinging to my guns and religion.
Posts: 683

Rep: Reputation: 63
Quote:
Originally Posted by john83reuben View Post
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.
 
Old 02-03-2009, 05:59 AM   #7
kebabbert
Member
 
Registered: Jul 2005
Posts: 527

Rep: Reputation: 46
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

Last edited by kebabbert; 01-31-2012 at 03:01 AM.
 
1 members found this post helpful.
Old 02-06-2009, 01:31 PM   #8
kebabbert
Member
 
Registered: Jul 2005
Posts: 527

Rep: Reputation: 46
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?
 
Old 02-06-2009, 04:09 PM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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
 
Old 04-01-2009, 05:55 AM   #10
kiranjith
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
http://www.linuxclues.com/articles/01.htm

simplest way that we can understand the difference
 
Old 01-30-2012, 10:52 PM   #11
krmanishsharma
LQ Newbie
 
Registered: Jan 2012
Posts: 1

Rep: Reputation: Disabled
Smile 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
 
Old 09-28-2012, 04:43 AM   #12
gopa
LQ Newbie
 
Registered: Aug 2011
Posts: 13

Rep: Reputation: Disabled
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

Last edited by gopa; 09-28-2012 at 04:45 AM. Reason: Added new line
 
1 members found this post helpful.
Old 09-29-2012, 03:08 AM   #13
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by gopa View Post
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.

Last edited by jlliagre; 09-29-2012 at 05:35 PM.
 
Old 09-29-2012, 05:14 PM   #14
gopa
LQ Newbie
 
Registered: Aug 2011
Posts: 13

Rep: Reputation: Disabled
@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
 
Old 09-29-2012, 05:43 PM   #15
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by gopa View Post
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
removing a soft link quietguy47 Linux - General 3 12-31-2011 09:34 PM
how to copy soft link hongxing Linux - Software 5 02-24-2010 07:14 AM
Soft Link and Hard Link Moataz Red Hat 1 04-25-2005 06:30 AM
Wat is a Soft Link? wed3k Linux - Newbie 2 08-19-2003 01:23 PM
Soft link help Pyroknight Linux - Newbie 1 02-06-2003 06:21 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration