An inode is an entry in inode table, containing information ( the metadata ) about a regular file and directory. An inode is a data structure on a traditional Unix-style file system such as ext3 or ext4.
Inodes store information about files and directories (folders), such as file ownership, access mode (read, write, execute permissions), and file type. On many types of file system implementations, the maximum number of inodes is fixed at file system creation, limiting the maximum number of files the file system can hold. A typical allocation heuristic for inodes in a file system is one percent of total size.
Inode consists of following attributes:
- File types ( executable, block special etc )
- Permissions ( read, write etc )
- UID ( Owner )
- GID ( Group )
- Time stamps including last access, last modification and last inode number change.
- File deletion time
- Number of links ( soft/hard )
- Location of ile on harddisk.
- Some other metadata about file.
A file’s inode number can be found using the
ls -il command. The
ls -il command prints the i-node number in the first column of the report.
# ls -il testfile.txt
24686 -rw-r–r– 1 root root 0 Jun 9 19:21 testfile.txt
Copy file: cp allocates a free inode number and placing a new entry in inode table.
Move or Rename a file: if destination is same filesystem as the source, Has no impact on inode number, it only changes the time stamps in inode table.
Delete a file: Deleting a file in Linux decrements the link count and freeing the inode number to be reused.