Commands related to inode in Linux
Inode number : Inode number also called index number .An Inode number points to an Inode. An Inode is a data structure that stores the following information about a file :
- Size of file
- Device ID
- User ID of the file
- Group ID of the file
- The file mode information and access privileges for owner, group and others
- File protection flags
- The timestamps for file creation, modification etc
- link counter to determine the number of hard links
- Pointers to the blocks storing file’s contents
Check Inodes on Filesystem
You can find a total number of inodes on disk by using ‘-i‘ option with df command
Find Inode number of File: To check inode number of file use following command. The first field in output is an inode number of the file.
ls -il filename
Inode Changes with Copy, Move and Delete :
Copy file: cp allocates a free inode number and placing a new entry in inode table.
cp v.txt v_.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.
mv filename path_where_you_want_to_copy
mv v.txt /home/cloudera
Delete a file: Deleting a file in Linux decrements the link count and freeing the inode number to be reused.
Commands to access Inode numbers
1) Ls -i Command :the flag -i is used to print the Inode number for each file.
2) Df -i Command: df -i command displays the inode information of the file system.
3) Stat Command:Stat command is used to display file statistics that also displays inode number of a file.
For more Rajasthan Technical University CSE-IV Sem Linux Programming Lab Experiments Click Here