Sunday, January 22, 2012

Understand UNIX / Linux Inodes Basics with Examples

Several countries provides a unique identification number (for example, social security number in the USA) to the people who live in that country. This makes it easier to identify an individual uniquely. This makes it easier to handle all the paper work necessary for an individual by various government agencies and financial institutions.

Similar to the social security number, there is a concept of Inode numbers which uniquely exist for all the files on Linux or *nix systems.
Inode Basics

An Inode number points to an Inode. An Inode is a data structure that stores the following information about a file :

    Size of file
    Device ID
    User ID of the file
    Group ID of the file
    The file mode information and access privileges for owner, group and others
    File protection flags
    The timestamps for file creation, modification etc
    link counter to determine the number of hard links
    Pointers to the blocks storing file’s contents

Please note that the above list is not exhaustive. Also, the name of the file is not stored in Inodes (We will come to it later).

When a file is created inside a directory then the file-name and Inode number are assigned to file. These two entries are associated with every file in a directory. The user might think that the directory contains the complete file and all the extra information related to it but this might not be the case always. So we see that a directory associates a file name with its Inode number.

Read more: The Geek Stuff
QR: http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=http://www.thegeekstuff.com/2012/01/linux-inodes/

Posted via email from Jasper-Net