What are the different link files in linux ?

A file in Unix/*nix environment consist of two part, a filename part and a data part.  File name is just a reference or a link to the data part. The data part is known as i-node and it is the i-node of a file which stores the information regarding the file like file permission, file location, file size etc... Usually a file's data is accessed by calling the filename. But there are methods by which same data can be accessed using several names. We call these methods Link. Links are divided into 2 types. They are

  1. Hard Link
  2. Symbolic Link

Hard Links

Hard Links are additional names for an existing file. A Hard Link when created with reference to an existing file points to the i-node of the original file. i.e. More than one filename will reference the same i-node number. So whether you call the original file or the hardlink, you are accessing the same i-node.


One limitation of a hardlink is that both the links (source file and the target file) should reside inside the same filesystem. This is because the i-node number allocated for a file in one filesystem might be allocated to some other file in another filesystem.  Also hard links are not allowed for directories in order to prevent loops in filesystem. 

Symbolic Link

Symbolic Links or Soft Links are special file type. A Soft Link points to the target file instead of the target file's i-node. i.e. soft links are reference to the original file. When you call a soft link you are redirected towards the original file. This is somewhat similar to a shortcut in a Windows machine.


A symbolic link can be created anywhere irrespective of the filesystem. One disadvantage of a symbolic link is that when the target file is deleted or moved the corresponding information is not updated to the symbolic link file and continues to point to the non-existing old target. Such a link is called a broken or dead link. 

Comments

Popular posts from this blog

Understanding awk command with examples

Understanding sed command with example -Part 1

How to install a Software in Linux