Go Back   TechArena Community > Software > Tips & Tweaks
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to use iNodes and Hard Links in Linux

Tips & Tweaks


Reply
 
Thread Tools Search this Thread
  #1  
Old 20-08-2010
Member
 
Join Date: Nov 2009
Posts: 583
How to use iNodes and Hard Links in Linux
  

iNodes and Hard Links :


Every file on your system by one inode represents (stands for "information node" (information node) and node is in English as "eye-" pronounced). An inode contains all information of the file. However, the inode is not immediately visible. Instead, each inode with the file system through one or more hard links linked. Hard links contain the name of the file and the inode number. The inode contains the file itself, for example, the location on the disk, permissions, file type and so on. The system can be found inode inode number of each basis.

A single file can have more than one hard link. This means that multiple file names can refer to the same (they are the same inode number that is connected). It may, however, occur no hard links between file systems. All hard links to a particular file (inode) must be on the same file system, since each file has its own inodes for file system and duplicate inode numbers may be different there.



Reply With Quote
  #2  
Old 20-08-2010
Member
 
Join Date: Nov 2009
Posts: 583
Re: How to use iNodes and Hard Links in Linux

Since all hard links to a file on the same file reference, you can change the file a name and then make under a different name watch the changes with:

Code:
techarena @ ~ $ cd echo "hello"> first link
cd changes in your home directory and places the file there first link to the word 'hello'contains. So redirecting the output of echo (echo is only the arguments) in the file first link to.
Code:
techarena @ ~ $ cat first link
Confirmed the contents of first link.
Code:
techarena @ ~ $ ln first link second link
Creates a hard link: second link now points to the same inode as first link.
Code:
techarena @ ~ $ cat second link
Confirmed that second link is the same as first link.
Code:
techarena @ ~ $ ls-l
Note that the number of hard links by first link and second link is 2.
Code:
techarena @ ~ $ echo "change">> second link



This is another shell redirection - do not take care of the details. We have the word "change"to second link attached. Check this with cat second link.
Code:
techarena @ ~ $ cat first link
first link also has the word "changeadded, "since first link and second link on the same file reference. It does not matter how you call the file when you make changes.
Code:
techarena @ ~ $ chmod a + rwx first link
Change the rights for first link. Give the command ls-l one, to see that the rights of second link were also amended. The rights are then stored in the inode, not the links.
Code:
techarena @ ~ $ rm first link
Deletes this link. This is a subtlety of rm - deletes it actually links, not files. Now enter ls-l one and see for yourself from the fact that second link is still there. Note also decreased by a number of hard links from second link.
Code:
techarena @ ~ $ rm second link
Clears the other link. If there are no links to a file anymore, Linux deletes the file itself - this is the inode. All files do so, even special types of files, such as devices (for example / dev / hda). A directory is simply a list of filenames and inode numbers - ie a list of hard links. If you are composing your hard link, you will add a new entry in the list of directories only. If you delete a file, you delete only one hard link from the Directory.
Reply With Quote
Reply

  TechArena Community > Software > Tips & Tweaks
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to use iNodes and Hard Links in Linux"
Thread Thread Starter Forum Replies Last Post
Two different hard disk for two different Linux UbuntuOSX Operating Systems 3 16-10-2009 01:01 PM
Difference between "Junction points" and "Hard Links" ? Carla Lacrosse Windows XP Support 7 02-03-2009 12:51 AM
Important Links for openSUSE Linux 11.1 release Rudra.J Operating Systems 1 16-02-2009 10:39 PM


All times are GMT +5.5. The time now is 10:47 PM.