Inode (Index node) is a data structure on file system that holds all information about file except its name and actual data. We can call inode as a identity card without name. When a file is create 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 same data for multiple files with different name.
Information Stored In Inode
Below information is stored in inode and each inode is numbered with unique number in file system.
- File type
- 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 is the inode number of html folder
Alternative way to get inode number and file information is stat command
$ stat output/
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd01h/64769d Inode: 1572894 Links: 3
Access: (0774/drwxrwxr--) Uid: ( 1000/ ismail) Gid: ( 1000/ ismail)
Access: 2016-11-13 15:59:31.716632708 +0300
Modify: 2016-11-13 15:59:31.716632708 +0300
Change: 2016-11-13 15:59:31.716632708 +0300
Find Files According To Inode
As inodes is 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 inode number.
$ find . -inum 1975176 -print
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