Junior
What is an inode?
sobes.tech AI
Answer from AI
Inode is a data structure in a file system (such as ext4, XFS, HFS+), which stores metadata of a file or directory. It describes the file system object but not its content. Every file and directory in the file system has its own unique inode.
Main information stored in an inode:
- File type: regular file, directory, symbolic link, block device, character device, socket, FIFO.
- Permissions: who (owner, group, others) has the right to read, write, or execute the file/directory.
- Owner UID: the user who owns the file/directory.
- Group GID: the group to which the file/directory belongs.
- File size: the number of bytes in the file.
- Creation time (ctime): the time when the inode was last changed (e.g., permissions or owner changed).
- Last access time (atime): the last time the file was read.
- Last modification time (mtime): the last time the file content was changed.
- Number of hard links: how many filenames point to this inode.
- Data block addresses: pointers to the blocks on disk where the file content is stored.
The inode does not contain the filename. Filenames are stored in directories. A directory entry links a filename to a specific inode.
You can view inode information using the stat command or ls -i.
Example of using ls -i:
# Display the inode number of the file my_file.txt
ls -i my_file.txt
Example of using stat:
# Display detailed information about the inode of the file my_file.txt
stat my_file.txt