Bird
Raised Fist0
Linux CLIscripting~5 mins

Inodes concept in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is an inode in a Linux file system?
An inode is a data structure that stores information about a file except its name and actual data. It holds metadata like file size, permissions, owner, and pointers to data blocks.
Click to reveal answer
beginner
Which command shows the inode number of files in a directory?
The command ls -i lists files with their inode numbers.
Click to reveal answer
intermediate
How does the inode relate to the file name?
The inode does not store the file name. The file name is stored in the directory entry that points to the inode number.
Click to reveal answer
intermediate
What happens if two file names point to the same inode?
They are called hard links. Both names refer to the same file data and metadata. Changes to one affect the other.
Click to reveal answer
advanced
Why can a file still exist if its name is deleted but the inode is not?
Because the inode keeps track of how many links point to it. If the link count is not zero, the file data remains until all links are removed.
Click to reveal answer
What does an inode NOT store?
AFile size
BFile name
CFile permissions
DPointers to data blocks
Which command shows inode numbers alongside file names?
Adf
Bls -l
Cls -i
Dstat
What is a hard link in terms of inodes?
AA file stored in a different directory
BA symbolic shortcut to a file
CA backup copy of a file
DTwo file names pointing to the same inode
If a file's name is deleted but the inode link count is not zero, what happens?
AThe file data remains accessible via other links
BThe file data is immediately deleted
CThe inode number changes
DThe file is moved to trash
Where is the file name stored in a Linux file system?
AIn the directory entry
BInside the inode
CIn the data blocks
DIn the superblock
Explain what an inode is and what information it contains.
Think about what details a file system needs to manage files besides their names.
You got /6 concepts.
    Describe the relationship between file names, inodes, and hard links.
    Consider how files can have more than one name pointing to the same data.
    You got /4 concepts.

      Practice

      (1/5)
      1. What does an inode in a Linux file system primarily store?
      easy
      A. The path to the file's location
      B. The file name and its extension
      C. Metadata about a file like permissions and size
      D. The content of the file

      Solution

      1. Step 1: Understand inode purpose

        An inode stores metadata such as file permissions, ownership, size, and timestamps, but not the file name.
      2. Step 2: Differentiate inode from file name storage

        The file name is stored separately in directory entries, not in the inode itself.
      3. Final Answer:

        Metadata about a file like permissions and size -> Option C
      4. Quick Check:

        Inode = Metadata [OK]
      Hint: Inodes store file info, not names or content [OK]
      Common Mistakes:
      • Thinking inode stores file names
      • Confusing inode with file content
      • Assuming inode stores file path
      2. Which command correctly shows the inode number of files in a directory?
      easy
      A. ls -i
      B. ls -l
      C. ls -a
      D. ls -h

      Solution

      1. Step 1: Recall ls command options

        The ls -i command lists files with their inode numbers.
      2. Step 2: Verify other options

        ls -l shows detailed info without inode, ls -a shows hidden files, ls -h shows sizes in human-readable form.
      3. Final Answer:

        ls -i -> Option A
      4. Quick Check:

        ls -i = inode numbers [OK]
      Hint: Use ls -i to see inode numbers quickly [OK]
      Common Mistakes:
      • Using ls -l expecting inode numbers
      • Confusing ls -a with inode display
      • Trying ls -h for inode info
      3. Given the output of ls -i shows two files with the same inode number, what does this indicate?
      medium
      A. The files are hard links pointing to the same data
      B. The files have identical names
      C. The files are located in different directories
      D. The files are symbolic links

      Solution

      1. Step 1: Understand inode sharing

        Two files with the same inode number mean they share the same data on disk, which happens with hard links.
      2. Step 2: Differentiate link types

        Symbolic links have different inodes; identical names or directories don't affect inode numbers.
      3. Final Answer:

        The files are hard links pointing to the same data -> Option A
      4. Quick Check:

        Same inode = hard links [OK]
      Hint: Same inode means hard links share data [OK]
      Common Mistakes:
      • Confusing symbolic links with hard links
      • Assuming same inode means same name
      • Ignoring inode uniqueness
      4. You run ls -i but get an error: ls: invalid option -- 'i'. What is the likely cause?
      medium
      A. Not having permission to list files
      B. Using a non-Linux system where ls lacks -i option
      C. Typing the command incorrectly as ls -l
      D. The directory is empty

      Solution

      1. Step 1: Analyze error message

        The error says invalid option -- 'i', meaning the ls command does not recognize -i.
      2. Step 2: Identify environment cause

        This often happens on non-Linux systems (like some Unix variants) where ls lacks the -i option.
      3. Final Answer:

        Using a non-Linux system where ls lacks -i option -> Option B
      4. Quick Check:

        Invalid option = unsupported ls -i [OK]
      Hint: Check OS if ls -i option fails [OK]
      Common Mistakes:
      • Assuming typo in command
      • Thinking permission causes option error
      • Assuming empty directory causes option error
      5. You want to find all files in a directory that share the same inode number (hard links). Which command pipeline helps you identify these files?
      hard
      A. find . -type l
      B. ls -i | sort | uniq -d
      C. ls -l | grep '^d'
      D. ls -i | cut -d' ' -f1 | sort | uniq -d

      Solution

      1. Step 1: Extract inode numbers from ls -i output

        The inode number is the first field in ls -i output, so use cut -d' ' -f1 to get it.
      2. Step 2: Find duplicate inode numbers

        Sorting and using uniq -d lists inode numbers that appear more than once, indicating hard links.
      3. Final Answer:

        ls -i | cut -d' ' -f1 | sort | uniq -d -> Option D
      4. Quick Check:

        Duplicate inodes = hard links [OK]
      Hint: Extract inode field then find duplicates [OK]
      Common Mistakes:
      • Using uniq -d without extracting inode field
      • Confusing symbolic links with hard links
      • Using find for symbolic links instead
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard