Home › Forums › Linux Questions & Answers.. › Filesystem .. › [File system] Hard link and soft link
- This topic has 2 replies, 1 voice, and was last updated 11 years, 8 months ago by
Humble.
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
Humble
KeymasterCan you explain what are hard and soft links? whats the difference between these?
Humble
KeymasterWell, common thing.. but let me put it in this way..
As everyone says, it comes into category of “link” files..
Hardlink:
Well, hard links point to the same INODE .. but the file names are different and both filenames point to the same inode..
You can create hardlink with ln command as shown below:
[root@humbles-lap ]# ln foo.bar foo1.bar1 [root@humbles-lap ]# ls -li foo* 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo1.bar1 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo.bar [root@humbles-lap ]# In first line, we created "hardlink" to the file called "foo.bar" in name of "foo1.bar1".. How-ever you can see both have same INODE number.. You can only have hardlinks within same filesystem. Also directories can not be hard linked.. Symlinks: symlinks are actually a special file containing a path to another file. When you operate on 'symlinked' filename , it actually access the file which is pointed inside symlink file. In short, symlinks store the path of the file it points too. Unlike hardlinks, symlinks can be on different filesystems.. With "-s" option of "ln" command you can create symlinks.. Please note that symlinks will have different inode numbers..
[root@humbles-lap ]# ln -s foo.bar foo.soft [root@humbles-lap ]# ls -li foo* 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo1.bar1 9443948 -rw-rw-r--. 2 hchiramm hchiramm 0 Jul 14 2013 foo.bar 9449878 lrwxrwxrwx. 1 root root 7 Feb 21 00:16 foo.soft -> foo.bar [root@humbles-lap ]# Please note, l in lrwxrwxrwx ..
Humble
KeymasterThis reply has been marked as private. -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)