Linux / UNIX: Display file inode (index number)

Linux / UNIX: Display file inode (index number)

To display the inode (index number) of a file in Linux or Unix, you can use the ls command with the -i option. For example:

ls -i file.txt
Sourc‮w:e‬ww.lautturi.com

This will display the inode number of the file file.txt.

You can also use the stat command to display the inode number, along with other information about the file. For example:

stat file.txt

This will display output similar to the following:

File: file.txt
  Size: 1234      	Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d	Inode: 12345678    Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/ user)   Gid: ( 1000/ user)
Access: 2021-01-01 12:34:56.000000000 +0000
Modify: 2021-01-01 12:34:56.000000000 +0000
Change: 2021-01-01 12:34:56.000000000 +0000
 Birth: -

The inode number is displayed under the Inode field.

You can also use the find command to search for files by inode number. For example:

find / -inum 12345678

This will search the entire file system (starting at the root /) for files with an inode number of 12345678.

Created Time:2017-10-29 22:08:56  Author:lautturi