Inode in the Linux File System

Tram Ho


When learning about the Linux file system, it is impossible to ignore the concept of inode. So here we go to find out what inode is and how it works!

What is Inode?

The Inode (index node) is an entity that supports the ordering of files in the Linux file system. Each filesystem object is represented by an inode that stores basic information about a file, a normal directory or another filesystem object. An empty file is equivalent to an inode with no data blocks.

Inode number

Each inode is identified by a unique inode number within the filesystem.

Inode numbering like

The inodes on a filesystem numbered 1 through 10 are reserved for use in the system. Inode 11 alone stores metadata files (storing information such as file size, permissions, users and user groups, …). All inodes are neatly stacked in one inode board. In addition, each inode for a file will also have information about the location of the data in the file system.

How to see the inode number of the file

To see the inode number of a file, you can use the command ls -i <file_name> . Or if, you want to see the inode number of all files in a directory, you can use the command ls -i <dir_name> .

For example, I want to see the inode numbers of all the files in the Public folder, the results will be returned as follows:

From the results we see the directories.txt file has an inode of 1836715 and the errors.txt file has an inode of 1840312.

Alternatively, you can also use the stat <file_name> command to check its inode number and properties:

What is Inode used for?

In fact, files created with special characters like?, ^, … cannot be easily deleted. Now, in order to delete the special files, we need to find the file’s inode number and delete it.
To delete fie with inode, we execute the following command: find . -inum <inode-number> -exec rm -i {} ;

Continuing with the above example, now, I will delete the ./Public/directories.txt file with the inode number:

After the deletion is complete, check to see if the ./Public/directories.txt file ./Public/directories.txt :

So we have successfully deleted the ./Public/directories.txt file with the inode number.


Thus, we have learned through the concept of inode, number of inode and effects of inode. Inode has many uses for organizing and managing files in Linux. The Inode meticulously stores basic information about the file and its location. See you in the following articles!

Share the news now

Source : Viblo