A short note on inode number – Linux

What is inode in Unix / Linux?

It’s simply a reference (idex) about the file and directory on the System. This is an entry in Inode table. This data structure uses to represent a file system object, this can be one of the various things such as file or directory.

The file system attributes include metadata like access time, modification time etc; as well as ownership and permission details of files and directories.

Sample image 1

inode

What are the important attributes?

The below mentioned keys are the different attributes in Unix file system:

  • File type.
  • File permission.
  • Ownership and group.
  • File size.
  • File access, change and modification time.
  • File deletion time.
  • Number of links.

Important difference between Soft link and Hard link

How do I check the inode details of a file or directory?

Do you have a shell access to your server? If so, yes! you can simply check the inode number by using the following commands:

 

  1. ls -i
  2. stat

See the sample outputs

1. By using ls command.

The switch “i” uses with ls command to find out the inode number of a file or directory. See the sample output pasted below:

arunlal@localhost:~$ touch inode.check

arunlal@localhost:~$ ls -i inode.check
1179765 inode.check

Here the inode for the file “inode.check” is 1179765.

2. By using stat command.

The “stat” command will display the inode number along with a lot of other attributes. See the output:

arunlal@localhost:~$ stat inode.check
  File: 'inode.check'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: 806h/2054d	Inode: 1179765     Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1000/ arunlal)   Gid: ( 1000/ arunlal)
Access: 2016-11-15 20:00:07.548968280 +0530
Modify: 2016-11-15 20:00:07.548968280 +0530
Change: 2016-11-15 20:00:07.548968280 +0530
 Birth: -

In this output you can see a lot of attributes of the file “inode.check.”

You can also use these commands to check the details of directories. See one example pasted below:

arunlal@localhost:~$ mkdir inode.check.dir

arunlal@localhost:~$ stat inode.check.dir
  File: 'inode.check.dir'
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 806h/2054d	Inode: 1314947     Links: 2
Access: (0775/drwxrwxr-x)  Uid: ( 1000/ arunlal)   Gid: ( 1000/ arunlal)
Access: 2016-11-15 20:09:21.734325138 +0530
Modify: 2016-11-15 20:09:21.734325138 +0530
Change: 2016-11-15 20:09:21.734325138 +0530
 Birth: -

That’s it.

 

Leave a Reply

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