IntroToLinux

5. Understanding Inodes

Inodes

What is an Inode?

An inode (index node) is a data structure that stores metadata about a file or directory.

Inode Information:

Working with Inodes:

# Show inode numbers
ls -i file.txt
ls -li directory/

# Detailed inode information
stat file.txt

# Find files by inode
find . -inum 123456

# Show inode usage
df -i                            # Inode usage per filesystem

# Check file system inode limits
tune2fs -l /dev/sda1 | grep -i inode

Practical Inode Concepts:

# Hard links share inodes
echo "test content" > original.txt
ln original.txt hardlink.txt
ls -li original.txt hardlink.txt    # Same inode number

# Soft links have different inodes
ln -s original.txt softlink.txt
ls -li original.txt softlink.txt    # Different inode numbers

# Monitor link counts
stat original.txt                   # Shows link count
rm hardlink.txt
stat original.txt                   # Link count decreased

Next: → Practical Labs
Previous: ← Understanding Links
Lesson Home: ↑ Lesson 6: Globbing & Archiving Course Home: ⌂ Introduction to Linux