What is inode number in Linux?

A short note on inode number – Linux/Unix

Inode number in Linux. It’s simply a reference (index) 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.

Inode number
Inode number

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.
  • Size.
  • Access, change and modification time.
  • 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.”

Top command usages and examples in Unix/Linux

Top command has an important role in Unix/Linux system/server administration side. The command “top” displays a dynamic view of process that are currently running under the system. Here I’m explaining some of the useful usage of top command for my Admin friends.

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.

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

One thought on “What is inode number in Linux?

  1. In today’s date Linux has so many version which is great for all, and after that, you will do it more and more. If you interested in it then you will do one thing you just visit some review and from there you will know it easily.

Leave a Reply

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