Techcuriosity
Resources
Free Tutorials
 
 
 
Linux Tutorials
• About Linux
• Linux Vs Windows
• Linux File Permissions
• Linux Directory Structure
• Linux Basic Commands
• Advanced Permissions in Linux
• Linux Server Admin Commands
• Semaphores in Linux
 
Linux Commands Glossary
 
• Linux Commands Glossary - Index
• Linux Commands A
• Linux Commands B
• Linux Commands C
• Linux Commands D
• Linux Commands E
• Linux Commands F
• Linux Commands G
• Linux Commands H
• Linux Commands I
• Linux Commands J
• Linux Commands K
• Linux Commands L
• Linux Commands M
• Linux Commands N
• Linux Commands O
• Linux Commands P
• Linux Commands Q
• Linux Commands R
• Linux Commands S
• Linux Commands T
• Linux Commands U
• Linux Commands V
• Linux Commands W
• Linux Commands X
• Linux Commands Y
• Linux Commands Z
 
Linux Articles
• Difference between Hard Link and Soft Link in Linux
 
Other Tutorials
• Exim Tutorials
• FTP Tutorials
• MySQL Tutorials
• Linux Tutorials
• Shell Scripting Tutorials
• Web Hosting Tutorials
 
Web Designing Tutorials
 
• HTML Tutorials
• Perl Tutorials
• Web Templates Editing Tutorials
 
Bio Tutorials
• BioInformatics Tutorials
• Perl Scripts Library
 
Curiosity Topics
• Online Data Security
• VDS Technology
• How Website Works?
• About Hacking
 
 
Home   |   About us   |   Services   |   Forum   |   Articles   |   Tutorials   |   Contact us
 


Gateway to End all your Curiosities in Information Technology and Bio-Informatics!!.. FREE turorials for Linux, Web designing, Web template Editing, Operating systems, New technology, Bioinformatics, Bioinformatics perl scripts, Clinical research and much more curious topics you need to know.  
Your IP address is: 38.107.191.105


Allwebco Website Templates

Find more Info related to your curiosities @ our FORUM


What is the difference between Hard Link and Soft Link in Linux?

Hard Link is a mirror copy of the original file. Hard links share the same inode.
Any changes made to the original or Hard linked file will reflect the other.
Even if you delete any one of the files, nothing will happen to the other.
Hard links can't cross file systems.

Soft Link is a symbolic link to the original file. Soft Links will have a different Inode value.
A soft link points to the original file. If you delete the original file, the soft link fails. If you delete the soft link, nothing will happen.
Hard links can cross file systems.

 

Difference between Hard Link and Soft Link in Linux

PERL
-

Lets learn the differnce with an example

Example: Create a file " original-file.txt "

:~/test$ echo "Learning about Hard and Soft Link" > original-file.txt
:~/test$ cat original-file.txt
Learning about Hard and Soft Link

Now lets create a Hard Link

Example: HardLink-file.txt

:~/test$ ln original-file.txt HardLink-file.txt
:~/test$ ls -il
total 8
840388 -rw-r--r-- 2 telson telson 33 2009-05-18 09:16 HardLink-file.txt
840388 -rw-r--r-- 2 telson telson 33 2009-05-18 09:16 original-file.txt

Now lets create a Soft Link

Example: SoftLink-file.txt

:~/test$ ln -s original-file.txt SoftLink-file.txt
:~/test$ ls -il
total 8
840388 -rw-r--r-- 2 telson telson 33 2009-05-18 09:16 HardLink-file.txt
840388 -rw-r--r-- 2 telson telson 33 2009-05-18 09:16 original-file.txt
840186 lrwxrwxrwx 1 telson telson 17 2009-05-18 09:23 SoftLink-file.txt -> original-file.txt

From the above ls -il result, you find the same inode for " HardLink-file.txt " and " original-file.txt ".
Inode value is different for the soft link " SoftLink-file.txt ".

Now lets try editing the original file:

Example:

:~/test$ cat >> original-file.txt 
Editing this file to learn more!!

:~/test$ cat original-file.txt 
Learning about Hard and Soft Link
Editing this file to learn more!!

:~/test$ cat HardLink-file.txt 
Learning about Hard and Soft Link
Editing this file to learn more!!

:~/test$ cat SoftLink-file.txt 
Learning about Hard and Soft Link
Editing this file to learn more!!

Now lets try changing the permissions:

Example:

:~/test$ chmod 700 original-file.txt 
:~/test$ ls -il
total 8
840388 -rwx------ 2 telson telson 67 2009-05-18 09:34 HardLink-file.txt
840388 -rwx------ 2 telson telson 67 2009-05-18 09:34 original-file.txt
840186 lrwxrwxrwx 1 telson telson 17 2009-05-18 09:23 SoftLink-file.txt -> original-file.txt

From the above example its clear that changing the permission of " original-file.txt " will update the permission set of " HardLink-file.txt ".
The soft link remains unchanged.

Now lets try deleting the original file.

Example:

:~/test$ rm original-file.txt 
:~/test$ ls -il
total 4
840388 -rwx------ 1 telson telson 67 2009-05-18 09:34 HardLink-file.txt
840186 lrwxrwxrwx 1 telson telson 17 2009-05-18 09:23 SoftLink-file.txt -> original-file.txt

:~/test$ cat HardLink-file.txt 
Learning about Hard and Soft Link
Editing this file to learn more!!

:~/test$ cat SoftLink-file.txt 
cat: SoftLink-file.txt: No such file or directory

So removing the original file will affect the Soft link. The Soft link fails.
Hard link is unaffected.

-
<< Previous    |     Next >>
 
© TechCuriosity.com 2006 - 2007. All Rights Reserved.
Designed and Maintained by Telson Thomas
Techcuriosity
Website News
Sponsored Links
• Allwebco Website Templates
• Flash Templates
• Web Templates
• Flash Templates store
• Free website templates
• Free Flash Templates
• Web Hosting
• Dedicated Server
 
• Advertise Here
 
Help us in our Mission
 
Twitter 
Our Network Sites
• Web Hosting Solutions
• SEO and Link Directory
 
Free Tutorials
• HTML Tutorial
• PERL Tutorial
• Exim Commands
• MySQL Commands
• FTP Commands
• Shell Scripting Tutorial
 
Member Login
Username:

Password:

 
Search for Curiosity
 
 
 
Forum Curiosity Topics
• Forum Index
• Operating System's
• Web Hosting
• Programming
• Bioinformatics
• Biology & Bio-Technology
• Computer Security
• Hacking
• General Curiosity
• Jobs
 
Newsletter Signup
 
Subscribe
 
 
• Link Directory
• SiteMap