Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hard Link? Soft Link ?

Posted on 1998-09-13
4
Medium Priority
?
1,845 Views
Last Modified: 2013-12-26
What is hard link and soft link? and what's the differences between them?
0
Comment
Question by:totoro030898
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1293193
Hard links point to the same inode
A soft or symbolic link is a special kind of file whose contents are the name of another file
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1293194
in addition to ozo's comment:

because of a hard link's nature (inode), hard links cannot cross partitions (usually),
while a symbolik link may point to a file/directory (or whatever is possible in a file system) anywhere, even on NFS

removing a hard links does not remove a file as long as it is not the last link count (no more hard links), removing the target of a symbolic link makes the file inaccesable
0
 
LVL 5

Expert Comment

by:yonat
ID: 1293195
Soft links are like "shortcuts" in MS Windows and "aliases" in Mac. A hard link is the same, only the is no one link is the "original" file - they are all equal (except for their paths).
0
 

Accepted Solution

by:
kokopeli earned 200 total points
ID: 1293196
Totoro,
Given the nature of your question, it might be helpful for you to have a little background on how files are accessed and organized by the UNIX system...
When you use a UNIX system, it stores your files on a disk that is segmented into one or more partitions, or slices.  Each of these partitions can have a distinct filesystem placed on it.  When a filesystem is created, objects called "inodes" are created.  Inodes store the location of an individual file and it's characteristics such as owner and permissions.  Whenever you ask to read or write a file the kernel will always resolve the filename that you provide into the associated inode number and then find the file using that number.

So, anyways, on to your link question...  When you create a soft (symbolic) link "ln -s" you are creating a new file with it's own new inode that just points to the name of the file you want.
However, when you create a hard link, you are actually just creating another file instance of the orignal file, both will have the same inode number (you can see inode numbers by doing an ls -i).  Once you create a hard link, there is no way to tell the original file from the hard link.  This leads to an interesting restriction, you cannot create a hard link which crosses filesystem boundaries/partitions.  The reason for this goes back to the fact that inodes are allocated for each filesystem, and are not managed by any central process.  Thus, you can have a file in one partition with the inode #100 and a completely different file in another partitions with inode #100....  so doing hard links across partitions would really screw things up.

- kokopeli
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question