Inodes in Linux
I must declare of which its a data structure of which keeps track in regards to a data file.
You store your information in a file, and the operating system stores the information about a file in an inode(sometimes called as an inode number).
Information about files(data) are sometimes called metadata. So you can even say it in another way, “An inode is metadata of the data.”
Whenever a user or a program needs access to a file, the operating system first searches for the exact and also unique inode (inode number), inside a table referred to as being an inode table. Actually the program or maybe anyone whom desires usage of the data file, actually reaches the particular data file through the particular inode number observed on the inode table.
To arrive at a specific data file with its “name” need an inode number matching compared to that data file. Although to reach an inode number you do not require the particular data file name. Infact with all the inode number you will get the data.
Inodes in Linux
An Inode number points to an Inode. An Inode is a data structure that stores the following information about a file :
Inode number Access Control List (ACL) Extended attribute Direct/indirect disk blocks Number of blocks File access, change and modification time File deletion time File generation number File size File type Group Number of links Owner Permissions Status flags
To check inode number of file use following command:
# ls -li techoism.txt
69124972 -rw-------. 1 root root 2910 Feb 3 22:49 techoism.txt
Copy Files
When we copy a file, a new file with a new inode is created.
# cp techoism.txt tech.txt # ls -li tech.txt techoism.txt
69124972 -rw-------. 1 root root 2910 Feb 3 22:49 techoism.txt 69124976 -rw-------. 1 root root 2910 Feb 4 20:56 tech.txt
Move Files
When moving file within a filesystem, the inode does not change, only the directory mapping of the inode is changed, the actual data on the hard disk (contents of file) does not move.
# mv techoism.txt /opt/techoism.txt # ls -li /opt/techoism.txt
69124972 -rw-------. 1 root root 2910 Feb 3 22:49 techoism.txt
Search File
Search file on basis of inode number:
# find / -inum 69124972
/root/techoism.txt
Remove Files
Remove the file using Inode number:
# find . -inum 69124972 -exec rm -rf {} \;
Enjoy it!