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.
Inode number also called as index number , it consists following attributes.
File types ( executable, block special etc ) Permissions ( read, write etc ) UID ( Owner ) GID ( Group ) FileSize 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.
To check inode number of file use following command, first field in ouput is an inode number.
# ls -il tecadmin.txt 1150561 -rw-r--r-- 1 root root 0 Mar 10 01:06 tecadmin.txt
Search file on basis of inode number.
# find /root -inum 1150561 /root/tecadmin.txt
What happen with inode when copy, move or delete a file:
Copy file: cp allocates a free inode number and placing a new entry in inode table.
# ls -il tecadmin.txt 1150561 -rw-r--r-- 1 root root 0 Mar 10 01:06 tecadmin.txt # cp tecadmin.txt tecadmin.net.txt # ls -il tecadmin.net.txt 1150562 -rw-r--r-- 1 root root 0 Mar 10 01:09 tecadmin.net.txt
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.
# ls -il tecadmin.txt 1150561 -rw-r--r-- 1 root root 0 Mar 10 01:06 tecadmin.txt # mv tecadmin.txt /opt/ # ls -il /opt/tecadmin.txt 1150561 -rw-r--r-- 1 root root 0 Mar 10 01:06 /opt/tecadmin.txt
Delete a file: Deleting a file in linux decrements the link count and freeing the inode bumber to be reused.
Thanks! very nicely explained
Good and Quick explanation….
awesome explain. Thanks
That was great … u can be a good mentor
thanks to explain keep it up.
Quite helpful. Very well explained. thnx