Soft link Vs Hard link in Linux/*NIX


Guest post by Sasi..


                                          Soft Link (Symbolic Link) & Hard Link
Soft Link

  • Soft or symbolic is more of a short cut to the original file....if you delete the original the shortcut fails and if you only delete the short cut nothing happens to the original.
  • A 'soft link' is a symbolic link to another file either on the same file system or a different file system. A 'soft link' may span file systems while a 'hard link' must point to a file on the same file system.
  • A soft link (or symbolic link) is just a way of accessing files (or directories) without moving them. You just have to associate the path of the file with a special type of file (a link) which will lead you directly to it. It is called soft by comparison to a hard link which has different properties.
  • A soft link is basically a file that contains the absolute path of the file it is pointing to. The file system tools simply know to follow the link in the file. This allows us to link across the system
Hard Link

hard link is more of mirror copy....does something to file1 and it appears in file 2
deleting one still keeps the other ok

Difference between hard link and soft link
Hard links share the same inode. Soft links do not.
Hard links can't cross file systems. Soft links do

In Linux, as in commercial Unix systems, the 'ln' command is used to create a symbolic link in file systems. A 'hard link' is a link pointing directly to a specific inode on the same file system.

An example of a partial 'ls -al' listing of a single line from a /dev directory on a Linux system which illustrates the appearance of a symlinked file follows:

lrwxrwxrwx 1 root root 3 Jan 13 22:05 cdrom -> hdc

In this example, the /dev/cdrom device is symlinked to the /dev/hdc device making them effectively one and the same though with different names. The leading 'l' in the 'lrwxrwxrwx' permissions listing indicates that the listing is a symbolic link. [JMH]

A hard link basically assigns another physical pointer to the same piece of data. This creates a limitation as it requires that the data be on the same logical disk as the link pointers location is designated by the inode of the data.


This is first guest post on my blog,Author of this post is having 4 years extnsive knowledge on most of the *NIX flavors you can reach him @ Sasikanth Padigala (spadigala@gmail.com)

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Related Posts by Categories



    0 comments:

    Archive

    Translate this page

     

    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here