find inode number in linux

How to Find Inode number of File in Linux

Every file in a Linux system has unique ID known as inode number. These unique IDs allow Linux system to easily manage files in its filesystem database. In fact, even directories have inode number, just like files. Sometimes you may need to determine the inode number of file in Linux. In this article, we will look at how to find inode number of file in Linux, using ls and stat command.


How to Find Inode number of File in Linux

ls command allows you to view the inode number of multiple files but stat command works with only single file/directory.


Using ls command

Here is an example to find out inode number of file in Linux. The -i option helps you get inode number.

$ ls -li
2944 drwxr-xr-x 16 www-data www-data     4096 Jul  4  2021 html
45570 drwxr-xr-x  5 www-data www-data     4096 Jul 10 21:48 wordpress

In the above output, the first column indicates the inode number. In our case, we have two directories html and wordpress with inode numbers 2944 and 45570 respectively. You can always use other options along with -i option in ls, as well as use wildcard characters to get a list of file details.


Using stat command

Here is the stat command to view inode number of single file. It basically provides lot of details about given file/directory, along with its inode number, given in bold.

$ stat ./html

You will see the following kind of output.

File: ./html
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 801h/2049d      Inode: 26944      Links: 16
Access: (0755/drwxr-xr-x)  Uid: ( 33/www-data)   Gid: (33/www-data)
Access: 2021-12-06 03:33:13.194964943 +0000
Modify: 2021-06-04 11:47:16.000000000 +0000
Change: 2021-12-06 12:33:05.246318669 +0000

Also read:

How to Create Ext4 Filesystem in Linux
How to Increase Inode Limit in Linux
How to Enable HAProxy Stats
How to Convert DEB to RPM Files in Linux
How to Configure Access Control Lists (ACL) in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *