What is inode number in Linux?

A short note on inode number – Linux/Unix

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. It’s a unique number for files and directories under a disk block/partition.

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

What are the important attributes included in inode?

The below mentioned keys are the different attributes in Unix file system and are included in inode.

  • 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: -

Total inode usage on the Linux machine can be calculated from the ”df” command along with the usage of switch “i.” Please see the details pasted below:

$ df -i
Filesystem      Inodes  IUsed   IFree IUse% Mounted on
udev            489347    557  488790    1% /dev
tmpfs           494198    802  493396    1% /run
/dev/sda6      3932160 238966 3693194    7% /
tmpfs           494198    150  494048    1% /dev/shm

That’s it! Try it and add comments if you have any other ideas on it.

Arunlal Ashok

Sr. Linux Server Administrator. I'm managing Linux servers since 2012. I started this blog to share and discuss my ideas. Check My Profile in uPwork (oDesk) and create a job, if you need any administration help. Thanks!!

You may also like...

Leave a Reply

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