What an Inode Is and How ls -i and stat Reveal It
An inode stores a file's metadata but not its name. See inode numbers with ls -i, read every field with stat, and learn why df -i can fill up first.

A disk can report 40 GB free and still refuse to create an empty file with No space left on device. The cause is often not space at all. The filesystem has run out of inodes, the fixed-size records that describe every file, and no amount of free blocks helps. This post explains what an inode is, what it holds and what it leaves out, and how ls -i, stat and df -i let you see all of it from a shell. It uses Linux 6.12 with an ext4 filesystem and GNU coreutils 9.5, and every number in the outputs is an example, because inode numbers differ on every machine.
What an inode stores
An inode (index node) is the on-disk record that describes one file. It holds everything the kernel needs to know about the file except its name:
the file type (regular file, directory, symbolic link, device node and so on)
the permission bits and the owner and group ids
the size in bytes and the number of blocks in use
three or four timestamps: access, modification, status change, and on ext4 also creation
the link count, the number of names that point at this inode
the location of the data, as a list of block extents
The name is missing on purpose. Names live in directories, and a directory is just a file whose data is a table mapping names to inode numbers. That split is what makes hard links possible: two names, one inode. The inode(7) manual page documents the fields the kernel reports for each one.
See the inode number with ls -i
Create a file and ask ls for its inode number:
cd "$(mktemp -d)"
echo "hello" > report.txt
ls -i report.txt1835042 report.txtThe number on the left is the inode number, unique within one filesystem. It is not unique across the machine: a file on another mount can have the same number. Your number will differ from 1835042.
A hard link adds a second name for the same inode:
ln report.txt copy.txt
ls -litotal 8
1835042 -rw-r--r-- 2 dev dev 6 Nov 23 10:02 copy.txt
1835042 -rw-r--r-- 2 dev dev 6 Nov 23 10:02 report.txtBoth names show the same inode number, and the 2 after the permissions is the link count. Edit one and the other changes, because there is only one file. Delete one name and the data stays until the link count reaches zero and no process holds the file open.
A symbolic link behaves differently. It is its own file with its own inode, whose data is a path string:
ln -s report.txt shortcut.txt
ls -li shortcut.txt1835050 lrwxrwxrwx 1 dev dev 10 Nov 23 10:03 shortcut.txt -> report.txtThe symlink has a different inode number and a size of 10, the length of the string report.txt.
Read the full record with stat
ls shows a slice. stat, which calls the stat(2) system call, prints the whole inode as the kernel reports it:
stat report.txt File: report.txt
Size: 6 Blocks: 8 IO Block: 4096 regular file
Device: 8,1 Inode: 1835042 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 1000/ dev) Gid: ( 1000/ dev)
Access: 2026-11-23 10:02:11.412083512 +0000
Modify: 2026-11-23 10:02:11.412083512 +0000
Change: 2026-11-23 10:02:41.870218344 +0000
Birth: 2026-11-23 10:02:11.412083512 +0000Read it line by line:
Sizeis the byte count, 6 (five letters and a newline).Blockscounts 512-byte units, not filesystem blocks. A 4096-byte block is 8 of them, which is why a 6-byte file shows8.IO Blockis the preferred transfer size, here 4096.Deviceis the major and minor number of the device holding the filesystem.Linksis the hard link count.Modifychanges when the data changes.Changechanges when the inode changes, for example afterlnorchmod. That is whyChangeis later thanModifyhere: thelncommand bumped the link count.
stat also takes a format string, which is the practical way to script against it:
stat -c '%i %h %s %F' report.txt copy.txt shortcut.txt1835042 2 6 regular file
1835042 2 6 regular file
1835050 1 10 symbolic link%i is the inode, %h the hard link count, %s the size and %F the file type.
Find every name for one inode
Since names are separate from inodes, you sometimes need to go from a number back to all of its names. find can do that inside one filesystem:
find . -xdev -inum 1835042./copy.txt
./report.txtThe -xdev flag stops find from crossing into other mounts, where the same number would mean a different file. This is also the cleanest way to delete a file whose name is awkward, such as one that starts with a dash or contains a newline: find it by inode and pass it to -delete.
Why df -i can fill up first
On ext4, the number of inodes is fixed when mkfs.ext4 creates the filesystem. By default it reserves one inode per 16 KiB of space for large filesystems, tuned by the -i and -N options. You can see the budget with df -i:
df -i /homeFilesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda1 6553600 412880 6140720 7% /homeWhen IUse% reaches 100%, creating any new file fails with ENOSPC even though df -h shows free space. The usual cause is a directory that collected millions of tiny files, such as a mail spool, a session store or a build cache. The fix is to delete files, not to free blocks. Filesystems such as XFS and Btrfs allocate inodes dynamically and do not hit this wall in the same way, which is one reason to pick them for workloads with many small files.
Read the same fields from C
The stat command is a thin wrapper over the stat(2) system call, and a program can read the same fields directly. This version prints the inode number, the link count and the size of each file named on the command line, using struct stat from <sys/stat.h> as documented in the stat(2) manual page:
#include <stdio.h>
#include <sys/stat.h>
int main(int argc, char **argv)
{
for (int i = 1; i < argc; i++) {
struct stat st;
if (stat(argv[i], &st) != 0) {
perror(argv[i]);
continue;
}
printf("%s: inode=%lu links=%lu size=%ld\n", argv[i],
(unsigned long)st.st_ino,
(unsigned long)st.st_nlink,
(long)st.st_size);
}
return 0;
}Compile it with GCC 14 using gcc -Wall -o inode_info inode_info.c and run it on the files from the earlier examples:
./inode_info report.txt copy.txt shortcut.txt missing.txtreport.txt: inode=1835042 links=2 size=6
copy.txt: inode=1835042 links=2 size=6
shortcut.txt: inode=1835042 links=2 size=6
missing.txt: No such file or directoryNotice that shortcut.txt reports the inode of report.txt. stat(2) follows symbolic links, so it describes the target, not the link. The lstat(2) call does not follow them and would return the symlink's own inode, with the size 10 that ls -li showed. When a tool such as find or tar must treat a link as a link, it uses lstat. That single difference explains why the stat command has a -L flag to dereference links and ls -l does not follow them by default.
Inodes and the directory table
It helps to picture what happens when you run cat report.txt. The kernel splits the path into components and, for each one, searches the directory's data for the name. A directory entry is little more than a name and an inode number, so finding report.txt in the current directory yields 1835042. The kernel then loads that inode, checks the permission bits against your user id, and reads the data through the block list the inode stores. The name is used once, at the start. After open(2) returns a file descriptor, the kernel refers to the file by its inode and never by its name again, which is why renaming or unlinking an open file does not disturb a program that already holds it.
This also explains a common surprise. Renaming a file inside one filesystem with mv changes only directory entries and leaves the inode untouched, so it is instant regardless of file size and the inode number survives. Moving a file to a different filesystem cannot work that way, since the new filesystem has its own inode table. mv then copies the data, creates a new inode, and removes the old one, which you can confirm by comparing ls -i before and after.
What an inode number is not
Do not treat an inode number as a stable identifier across time. After a file is deleted and its inode freed, the filesystem may hand the same number to a brand new file. Backup tools that match files by inode number alone are wrong on busy filesystems; the pair of device and inode, plus the modification time, is the usual defense. Do not use it across filesystems either, as noted above, and do not assume the numbers are ordered by creation.


