answersLogoWhite

0


Best Answer

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.

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.

User Avatar

Wiki User

โˆ™ 2012-07-01 09:39:11
This answer is:
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
User Avatar
Study guides

Software and Applications (non-game)

21 cards

What is a programming language

What does DOS stand for

What is a software that is distributed for free

What is application software

โžก๏ธ
See all cards
2.43
โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…
7 Reviews

Add your answer:

Earn +20 pts
Q: What is hard link and soft link in Linux?
Write your answer...
Submit
Related questions

What is link count in Linux?

Link Counts In linux there are basically two types 1.soft links 2.hard links


How many Types of Link file in Linux?

two types hard linking and soft linking


What is the difference between hard link and soft link in Linux?

A hard link usually links a file to another file or directory on the same partition. A soft link can point to any file or directory anywhere on the system.


What is the difference between soft links and hard links in UNIX?

To create soft link(symbolic link) for particular file "f1" command is 'ln -s f1 sf1'. For hard link command is 'ln f2 hf2'. Soft link having different inode no from it's original file f1,hard link having same inode no as it's original file f2. Soft link can create directories but hard link can't. Hard links created within that particular file system but soft link cross that file system .


Why Unix does not allow ordinary users to create hard links?

You don't have to be a privileged user to create a hard link; most of the time they aren't as desirable as soft links because with a hard link the file must be present to create the link. In addition, there are some restrictions about going across file systems with a hard link that do not exist as a restriction with a soft link.


What is the taco commercial of the children yelling hard soft hard soft until one little girls says something about having both and what's the link?

it's not about tacos! and you don't want to know the link!


What is the difference between soft and hard information?

soft information is soft . hard information is hard.


Is breakwater hard or soft engineering?

it is hard and sometimes soft


Where can you download DeLi Linux?

DeLi Linux can be downloaded from the project's website at the link below.


Where can you download the Linux kernel?

The Linux kernel sources can be downloaded from the official Linux Kernel Archives, found at the link below.


What is the different of soft bones and hard bones?

soft you can bend and hard you can not


Is gold soft or hard?

Gold is soft and hard, gold is hard when it has metal plating and soft when there isn't metal plating.


Are igneous rocks soft or hard?

Igneous rocks are mostly hard, not soft.


Is brown soft or hard?

Soft


Is sulfur hard or soft?

soft


Are Dolphins Hard Or Soft?

soft


Is magnesium hard or soft?

soft


Is sedimentary hard or soft?

soft


Is neptunium hard or soft?

Soft


What kind of soft ware is Linux?

Linux is an operating system on which a wide array of system distributions (Such as Ubuntu and Android.) are built.


How are soft and hard polyps different?

one is soft and the other is hard


Why metallic solids is soft to hard?

why metallic solids are soft to hard


How many calories in a 1 inch cube of goat cheese?

It depends whether the cheese is hard, soft or semi-soft. For the calories in in hard, soft and semi-soft goat's cheese by weight, please see the page link, further down this page, listed under Related Questions.


What are the 3 consonants that can be hard and soft?

I'm pretty sure only "g" and "c" can be either hard or soft. Example: Girl (hard) and giant (soft) Cool (hard) and circus (soft)


How do you get rid of Linux?

By formatting the hard drive.