An inode is a data structure that contains metadata about a file. When the file system stores a new file on the hard disk, it stores not only the contents (data) of the file, but also extra properties like the name of the file, the creation date, its permissions, the owner of the file, and more. All this information (except the name of the file and the contents of the file) is stored in the inode of the file. The ls -l command will display some of the inode contents, as seen in this screenshot

#ls -ld <directory_name>

The inode table contains all of the inodes and is created when you create the file system (with mkfs). You can use the df -i command to see how many inodes are used and free on mounted file systems.

#df -i

In the df -i screenshot above you can see the inode usage for several mounted file systems. You don’t see numbers for /dev/sda2 because it is a fat file system.

inode number

Inode number is also known as index number. It is a unique number assigned to files and directories while it is created. The inode number will be unique to entire filesystem. You can see the inode numbers with the ls -li command.

#ls -li

These three files were created one after the other and got three different inodes (the first column). All the information you see with this ls command resides in the inode, except for the filename (which is contained in the directory).

inode and file contents

Let’s put some data in one of the files.

The data that is displayed by the cat command is not in the inode, but somewhere else on the disk. The inode only contains a pointer to that data.

The following two tabs change content below.
Ruwantha Nissanka is a Professional Cyber Security Engineer from Sri lanka with having a demonstrated history of providing cyber security services for multiple organizations in Sri Lanka. He is a positive person who wants to believe the best in others and he likes to help, encourage people and make them feel good.