Wednesday, April 3, 2013

Links soft and hard

Soft Link (Synbolic link):
 Symbolic links are names that reference other files. It can refer to other directory also. Soft link can be made across file systems .
Hard Link : 
When a hard link is made, then the i-numbers of two different directory file entries point to the same inode. Thats why hard links cannot span across file systems.
Unlink command is used to delete link.
unlink on hard link decreases i -count and if only one refrence is there it will delete file
-------------------------------------------------------------
$ touch foo
$ ls -i
538639 foo
$ ln -s  foo bar   // make soft link
$ ls -i
538643 bar  538639 foo    // inode no are different
$ ln foo bar_h    // make hard link
538643 bar  538639 bar_h  538639 foo      // inode no for hard link is same as source.

$ ls -l bar_h
-rw-r--r-- 2 user1 user1 0 2011-04-03 11:18 bar_h
 2  here means no of Hard links
----------

No comments: