Friday, November 4, 2011

what is File links in Linux / Unix

Hi friends,

Now we will discuss about the links in Linux OS and little bit an Inode because it's part of links. Your comments and suggesstion are welcome.

Links is very usefull in Linux and Unix Operating system but it should be properly applied.
In short Links means if your file present anywhere in file systems and that file has mirror copy.
Assume that file “abcd.doc” you have created. While creating file Linux system gives a unique an INODE number to the file. All files and directories has a an Inode number.
The inode contains information about the file. (Information is file type, permission, User ID, Group ID, File size, File save date and time, location of the file on HDD).

To see an Inode number of the file command is :-

ls -il

Now coming back to link files, In Linux/Unix systems there are two types of links First symbolic or soft link and second is hard link.

Sybmbolic or Soft link :- Two inodes will create one contains the actual data of the file, the other serves as a pointer to the first file, containing only the first file's name. Symbolic links may point to any file or directory irrespective of the volumes on which the source and destination reside.
Symbolic links refer to a symbolic path indicating the abstract location of another file.

Command is for to create a symbolic link is :-

ln -s abcd.doc abcd_new.doc

If you want to link in a separate directory

ln -s /usr/abcd.doc /var/abcd_new.doc

Command for link remove is :-

unlink /var/abcd_new.doc

This command will stop the link between original file and copy of the file and also remove the copy of the file.

Hard Link : This link will not create two Inodes. Link file will share Inode of original file.
HardLink cannot links directories and also cannit cross file system.
Hard links, refer to the specific location of physical data.

Command for to create hard link :-

ln abcd.doc abcd_new.doc

1 comment:

  1. Hi guys,

    I welcome your comments and views, If you have any query or question please feel free to ask me.

    Thanks and regards,

    Anand Mane.
    email:- anandbmane@gmail.com

    ReplyDelete