When you see a file name, you are not looking at the file itself. On Linux filesystems such as ext4, each file is described by an inode.
What an inode holds
An inode records the file's metadata:
- type (regular file, directory, link and so on)
- permissions, owner and group
- size
- timestamps
- link count
- where the data blocks are
It does not hold the file name. Names are stored in directories, which are essentially lists pairing a name with an inode number.
Seeing inode numbers
$ ls -i notes.txt
787946 notes.txtstat shows much more (output shortened):
$ stat notes.txt
File: notes.txt
Size: 15 Blocks: 8 IO Block: 4096 regular file
Device: 252,15 Inode: 787946 Links: 1
Access: (0644/-rw-r--r--) Uid: (1000/ sam) Gid: (1000/ sam)
Modify: 2026-01-05 10:12:25
Change: 2026-01-05 10:12:25The layout varies a little between versions. Modify is when the contents changed. Change is when the inode itself changed, for example after chmod. Access is when it was last read, though mount options often limit how frequently that is updated.
What follows from this
Inode numbers are unique only within one filesystem.
Moving a file within the same filesystem with mv just changes directory entries, so the inode stays the same and it is instant. Moving to another filesystem copies the data into a new inode and removes the old one.
Removing a file with rm removes a name and lowers the link count. The space is freed once the count reaches zero and no process has the file open.
Inode limits
ext4 sets the number of inodes when the filesystem is made, and you cannot simply add more later without resizing it. Many tiny files can use them all while space remains. Check with:
$ df -i /
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/sda2 5242880 1454288 3788592 28% /Some filesystems, XFS among them, allocate inodes as needed, so the limit behaves differently.
Try it
Create a file, record its number with ls -i, rename it with mv and check again. The number should be unchanged. Then run chmod 600 on it and compare the stat times. The files and links lab is a good place to experiment.
Check your understanding
Inodes
All 5 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.