The file or directory contains many information about the file or directory itself, but how to view these file information and directory information??? The Linux stat command can be use to view the file information including their inode number... The step by step command example below show the use of stat command to view file inode information and directory inode information in Linux Fedora system.
View inode information for file.
1. The stat command below show the inode information for passwd file located under /etc directory
[root@fedora ~]# stat /etc/passwd
Size: 2911 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 324438 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2008-08-11 05:24:17.000000000 -0400
Modify: 2008-08-03 05:11:05.000000000 -0400
Change: 2008-08-03 05:11:05.000000000 -0400
View directory inode information.
1. The stat command example below show the root home directory inode information located under / (root directory).
[root@fedora ~]# stat /root
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd00h/64768d Inode: 343393 Links: 30
Access: (0750/drwxr-x---) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2008-08-11 05:36:00.000000000 -0400
Modify: 2008-08-11 05:33:07.000000000 -0400
Change: 2008-08-11 05:33:07.000000000 -0400
The inode information contains:
- Inode number
- Mode information to discern file type and also for the
- Number of links to the file
- UID of the owner
- Group ID (GID) of the owner
- Size of the file
- Actual number of blocks that the file uses
- Time last modified
- Time last accessed
- Time last changed