Operating System - HP-UX
1833420 Members
3200 Online
110052 Solutions
New Discussion

what is the difference between softlink and hardlink

 
ezhilarasan_1
Occasional Advisor

what is the difference between softlink and hardlink


Hi,

what is the difference between softlink and hardlink ?

Normally from target dir we create link for a file or dir as like below

ln -s /home/testfile1

I came to know that this softlink.
But I do n't know the difference between them.
BTW, how to create hard link.

Thanks
Ezhil


5 REPLIES 5
Bharat Katkar
Honored Contributor

Re: what is the difference between softlink and hardlink

Hi Again,
SOftlink can link both files and directories which may or may not belong to same filesystems whereas Hardlink can be created for only those files that are in same filesystem.

You can't create hardlink across the filesystems, you have to create softlink in that case.

Hope that helps.
Regards,
You need to know a lot to actually know how little you know
Victor Fridyev
Honored Contributor

Re: what is the difference between softlink and hardlink

Hi,

The main difference between hard and soft link is the following: hard link is a real file and a soft link is a pointer to a file.
If FILN is a file; so after
ln FILN HFILN
ln -s FILN SFILN
rm FILN

HFILN exists as contains all data before removing
SFILN has nothing

Additional difference is that soft link can be built across file systems.

HTH
Entities are not to be multiplied beyond necessity - RTFM
Muthukumar_5
Honored Contributor

Re: what is the difference between softlink and hardlink

you can know the difference with in the attachment.

HTH.
Easy to suggest when don't know about the problem!
Sยภเl Kย๓คг
Respected Contributor

Re: what is the difference between softlink and hardlink

Hi Ezhil
Link file are the files which actually a pinter to it's master file or directory.

1.In the case of a Hard Link the link to a file or directory can be crated and used only in the same filesystem.You cannot have the main file to be reside in one filesystem and it's link in an another file system.
2.Softlinks are also called as symbolic links.Softlinks can cross the filsystem boundaries.
ie a link can pint to a file or diretciry which resides in any of the filesystem .

Softlink can be created using ln with -s switch where hardlink is created by ln without any switches.

Hope u are clear now

regards
SK
sunilhcl@rediffmail.com
Your imagination is the preview of your life's coming attractions
Thomas Bianco
Honored Contributor

Re: what is the difference between softlink and hardlink

there are a lot of answers, but Iâ m not happy with any of them.

a hardlink is a reference to the physical sector that contains the information on the filesystem. all files have at least one hardlink, and thatâ s how they appear on the tree. For instance, /etc/fstab is a hardlink to some inode on some filesystem that contains the filesystem table. if you were to hardlink /etc/someotherfstab, it point to the same inode.

a softlink, or symbolic link, is a reference to a specific path in the file tree. it is essentially a special file that contains the path to another file that is "dereferenced" by the kernel (i think, could be shell) before it is passed to the calling program. it contains no information.

because hardlinks reference the physical sectors, they cannot cross filesystems. because softlinks are dereferenced by the kernel, they may not always point to the same information if mounted on different trees.

imagine the instance where you have a softlink to /etc/fstab on a removable disk (like a floppy). no matter what system you mounted it on, it would always point to /etc/fstab on the local sys
There have been Innumerable people who have helped me. Of course, I've managed to piss most of them off.