In computing, an inode (index node) is a data structure found in many Unix file systems. Each inode stores all the information about a file system object (file, device node, socket, pipe, etc.), except data content and file name.
A file system relies on data structures about the files, beside the file content. The former is called metadata—data that describes data. Each file is associated with an inode, which is identified by an integer number, often referred to as an i-number or inode number. 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. The inode number indexes a table of inodes in a known location on the device; from the inode number, the file system driver portion of the kernel can access the contents of the inode, including the location of the file allowing access to the file. A file's inode number can be found using the ls -i command. The ls -i command prints the i-node number in the first column of the report.
File names and directory implications:
- inodes do not contain file names, only file metadata.
- Unix directories are lists of association structures, each of which contains one filename and one inode number.
- The file system driver must search a directory looking for a particular filename and then convert the filename to the correct corresponding inode number.
Examples
$ touch "test" #no spaces
$ touch "test " #spaces in the end
$ ls -il test*
1079211 -rw-r--r-- 1 root users 0 Oct 12 15:13 test
1079212 -rw-r--r-- 1 root users 0 Oct 12 15:13 test
The first column is the inode. It can be shown in two ways:
$ stat filename
$ ls -i filename
Deleting a filename using inode:
find -inum inodenumber -exec rm {} \;
Links