Sobes.tech
Junior

What is the purpose of inode in a file system?

sobes.tech AI

Answer from AI

An inode (index descriptor) stores metadata about a file or directory in a Unix-like operating system's file system. It does not contain the actual content of the file.

What is stored in an inode:

  • File type (regular file, directory, symbolic link, etc.)
  • Access rights (owner, group, others; read, write, execute)
  • Number of hard links to the file
  • UID (User ID) of the owner
  • GID (Group ID) of the owner
  • File size (in bytes)
  • Creation time (ctime - change time)
  • Data modification time (mtime - modification time)
  • Last access time (atime - access time)
  • Disk block addresses where the file content is stored

Each file or directory is assigned a unique inode number within the file system. This number is used by the kernel to access the corresponding data object description.

Example of inode information output using the ls -i command:

# Output inode number of the file
ls -i my_file.txt

Example of using the stat command for detailed inode information:

# Output detailed information about the file, including inode data
stat my_file.txt