Linux / Unix: Find Inode Of a File Command

How do I find out an inode (index-node) of a file under Unix like operating systems?

An inode number stores all the information about a regular file, directory, or other file system object, except its data and name. To find an inode, either use the ls or stat command.

ls Command: Display Inode

$ ls -li filename
$ ls -li /etc/resolv.conf

Sample outputs:
25766494 -rwxr-xr-x 1 root root 332 May 5 14:14 /etc/resolv.conf
25766494 is inode number and the -i option displays the index number (inode) of /etc/resolv.conf file.

stat Command: Display Inode

You can also use the stat command as follows:
$ stat fileName-Here
$ stat /etc/passwd

Sample outputs:

  File: `/etc/passwd'
  Size: 1644      	Blocks: 8          IO Block: 4096   regular file
Device: fe01h/65025d	Inode: 25766495    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2012-05-05 16:29:42.000000000 +0530
Modify: 2012-05-05 16:29:20.000000000 +0530
Change: 2012-05-05 16:29:21.000000000 +0530

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • Fazhrie May 30, 2012 @ 15:39

    Everything has its pros and cons.Unix came first. Linux was born from it. UNIX: used for really big sytmess. more stable. good for doing standard things or old internet things.LINUX: more toys. tends to be prettier. popular for personal servers and desktop machines. good for doing newly thought of things on the netThink of Unix as a semi-truck and Linux as a hot car. Both can be used to haul freight or drive around town but the best choice for each is pretty obvious.

  • SAlder Aug 1, 2012 @ 16:00

    ‘ls -i ‘ number to the far left is the inode.

  • marty Mar 3, 2013 @ 6:26

    The only time I’ve even needed to know the inode number is if I have a file with some very strange name that prevents me from (easily) using “rm”.

    I get into the parent directory then use (from memory, I haven’t actually had my hands on a unix box in a while) find . -exec ls -i {} \;

    That could be grossly wrong somehow, but I’m sure someone will jump in.

    I can then use “rm” to remove the inode number and not need the file name. Seems to me that I might have had to use that find/exec thing again.

  • Srini Oct 23, 2014 @ 10:48

    df -i

    This will display fs, inode, iused, ifree, iuse%, mount on….

    • Nagaraju May 26, 2015 @ 2:20

      Hi srini,



Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum