What Are Inodes In Linux? – POFTUT

What Are Inodes In Linux?

Inode (Index node) is a data structure on the file system that holds all information about a file except its name and actual data. We can call inode as an identity card without a name. When a file creates a new name and inode is assigned to it. There is two way to fill a disk. One way is to fill all segments in the file system other way is to consume all inode index numbers. Detaching names from inode gives file systems the ability to hard link which means using the same data for multiple files with a different name.

Information Stored In Inode

Below information is stored in the inode and each inode is numbered with a unique number in the file system.

  • File type
  • Permission
  • Owner
  • Group
  • File Size
  • File Access, Deletion and Modification Time
  • Number of Links(soft/hard)
  • Access Control Lists (ACL’s)

List Inode Number

We can list inode number with ls command

$  ls -i
1187182 html
  • 1187182 is the inode number of HTML folder

An alternative way to get inode number and file information is stat command

$ stat output/
Print inode Information
Print inode Information

We can see that the following information is provided by stat command about the output directory.

  • `Size` is the size of the given directory and all content of the directory
  • `Block` is the total block count
  • `IO Block`
  • `Device`
  • `Inode` number is the number of the specified folder
  • `Links` provides total count of links to this folder
  • `Access` part provides rights about this folder from owner, group and others perspective.
  • Owner `Uid`
  • Owner `Guid`
  • `Acces` time
  • `Modify` time
  • `Change` time
LEARN MORE  How To Compress Files and Folders In File System Level With Compact Command In Windows NTFS?

Find Files According To Inode

As inodes are base for the file systems they can provide a lot of useful things. One of them is searching according to inode number. Linux find command can search not just file and directory names it can also search and find inode numbers. We will use -inum option in order to search according to the inode number.

$ find . -inum 1975176 -print
Find Files According To Inode
Find Files According To Inode

Delete Files With Inode

Another useful case for inode number is deleting files accord to their inode number. This can be especially useful for strange character files we can not type in the terminal. We will use find command again but provide the -delete option in order to remove file.

$ find . -inum 1975 -delete

Leave a Comment