How to Find Inode Number in Ubuntu Linux
In the Linux operating system, specifically Ubuntu, every file is associated with a unique identifier known as an inode number. This number is crucial for system administration tasks such as tracking file usage, debugging filesystem issues, or managing hard links. This article explains the specific command used to reveal these numbers and provides additional context on how to interpret the output effectively.
The Primary Command
The most common command to reveal the inode number of a file in
Ubuntu is ls -i. This command lists directory contents
while including the inode number for each file.
To use it, open your terminal and type:
ls -i filename
Replace filename with the actual name of the file you
wish to inspect. If you want to see the inode numbers for all files in
the current directory, simply run:
ls -i
Using the Stat Command
Another powerful tool for this purpose is the stat
command. It provides detailed file status information, including the
inode number.
Run the following command:
stat filename
Look for the line labeled Inode: in the output. This
method provides more metadata than ls -i, such as access
rights and modification times, alongside the inode.
Understanding Inodes
An inode is a data structure on a filesystem that stores all information about a file except its name and actual data content. Knowing the inode number helps identify files that share the same data on the disk, known as hard links. If two files have the same inode number, they are hard links to the same underlying data.
Summary
To quickly check an inode number, use ls -i. For
detailed file information including the inode, use stat.
Both commands are built into standard Ubuntu installations and require
no additional software.