What is inode in linux

Published on Author bloggereightLeave a comment


Inode contains info about the file-size, location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode. In addition to descriptions about the file, the inode contains pointers to the data blocks of the file. If the file is large, inode has indirect pointer to a block of pointers to additional data blocks (this further aggregates for larger files). A block is typically 8k.
Inode consists of the following fields:

* File owner identifier
* File type
* File access permissions
* File access times
* Number of links
* File size
* Location of the file data

[a] ls command : list directory contents

[b] stat command : display file or file system status

Type ls command with -i ( print the index number of each file ) option:
$ ls -i /etc/passwd

752010 /etc/passwd

752010 is index number (inode) for /etc/passwd file.
stat command

$ stat /etc/passwd

File: `/etc/passwd’
Size: 2026 Blocks: 8 IO Block: 4096 regular file
Device: 811h/2065d Inode: 752010 Links: 1
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2007-08-20 23:19:20.000000000 +0530
Modify: 2007-07-07 00:06:56.000000000 +0530
Change: 2007-07-07 00:06:56.000000000 +0530

You can use inode number to delete or search a file.



Leave a Reply

Your email address will not be published. Required fields are marked *