The inode I never knew
AnthonyEnglish 270000RKFN Visits (19918)
When you change permissions on a file, the file contents aren't affected. The change is made to the i-node.
So what's an inode?
A quick visit to Wikipedia explains:
All of that file "header" information is known as metadata. Here's how it is explained by the whitepaper, Inproving Database Performance with the AIX Concurrent I/O. My emphases in bold and my comments are in red.
2.2 Inode LockingEnd of quotation.
You can see a lot of the inode (metadata) information using the ls -l command:
And you can have a look at the inode in more detail with the AIX istat command:
Last updated and Last modified
There are two fields on the istat command you might be wondering about: Last updated and Last modified.
Last updated shows the date and time of the last i-node update.
Last modified shows the date and time of the last file modification, in other words, the file contents.
A perm change
Now, supposing I change the group from staff to mail:
You can see the new group is mail. Notice that the date and time stamp in ls -l hasn't changed, because I didn't modify the file contents. The change to the group access has only changed the metadata.
So now, let's update the file contents and see the result:
Quick edit of file, using our AIX Down Under advanced typing skills. [Time for you to have a coffee ... ]
[... several minutes later ... ]
OK welcome back
I added a single character to the file, so the file size has changed from 254 to 255 bytes. The ls -l shows the file modification time has been updated.
ls -la .profile
Both of those changes will be shown on the istat command output:
istat .profileFun with inum
If you want to list the inode number for a file, you can use the istat command, or simply add the -i flag to your ls -l command:
The inode number is 13 (not a lucky number for Unix people, because it usually indicates a permissions problem. Not this time, though).
You can find a file by its inode number:
find . -inum 13This can be helpful if you have a file with strange characters for its name. You can delete or rename the file by identifying it by its inode number.
The inode number is unique withing a file system. So if you started this find command from a directory which contains several file systems underneath it, you might find several files.
There are other things worth knowing about the inode, especially some of the options for the find command:
-atime to search by access timeThere are some options for the find command to search by file modification time, access time etc. in minutes:
-mmin nYou get the idea. See the find command documentation for more details.
It's helpful to know about inodes. It can help you understand Concurrent I/O (cio) which you may set as a mount option on some database file systems. Have a read of the relevant section from the Improving Database Performance with the AIX Concurrent I/O whitepaper. It also gives a good explanation of inode locking.
Many sys admins go through their lives without knowing what an inode is. Using ls -l (with their favourite flags - everybody's got their own) was enough to carry them through. But if you do need to do a search for files by something other than their names, having a grasp of what inodes are about is a help. Thanks to that whitepaper on Concurrent I/O and some handy command documentation, when someone starts to give you an unsolicited lecture about inodes, you'll be able to tell them "I know dat."