An inode is a data structure in Unix and Linux file systems, which contains information about a file or directory such as its size, owner, device node, socket, pipe, etc. There are two commands that can be used to view a file or directory’s inode, and they are ls and stat.
Using ls command:When used with the -i flag the ls command results for each file containing the file’s inode number:
Example:
$ ls -li
276944 -rw-r--r-- 1 root root 337 Oct 4 11:31 /etc/hosts
Using stat command:The example will show status of the /hosts directory seen above:
Example:
$ stat ./hosts
File: ./hosts
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 801h/2049d Inode: 276944 Links: 16
Access:(0755/drwxr-xr-x) Uid: (33/www-data) Gid: (33/www-data)
Access: 2019-12-06 13:33:13.194964943 +0000
Modify: 2019-06-04 01:47:16.000000000 +0000
Change: 2019-12-06 13:33:05.246318669 +0000