Linux/Unix – find inode number of a file

To find the inode number of a file on Linux/Unix the following approaches can be used.

Find inode using ls

$ ls -i file1.txt 
412882 file1.txt

Find inode using stat

$ stat file1.txt 
  File: ‘file1.txt’
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: ca01h/51713d	Inode: 412882      Links: 1
Access: (0664/-rw-rw-r--)  Uid: ( 1001/    gopj)   Gid: ( 1001/    gopj)
Access: 2016-04-16 08:17:16.218080999 +0000
Modify: 2016-04-16 08:26:18.154080999 +0000
Change: 2016-04-16 08:26:18.154080999 +0000
 Birth: -

To display only inode

$ stat --format "%i" file1.txt
412882
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments