Bird
0
0

You run head -n 5 file.txt but get an error: head: invalid option -- 'n'. What is the likely cause?

medium📝 Debug Q14 of 15
Linux CLI - Viewing and Editing Files
You run head -n 5 file.txt but get an error: head: invalid option -- 'n'. What is the likely cause?
AThe file <code>file.txt</code> does not exist
BThe <code>head</code> command version does not support <code>-n</code>
CYou need to use <code>--lines=5</code> instead of <code>-n 5</code>
DYou must run the command as root
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the error message

    The error says invalid option -- 'n', meaning -n is not recognized.
  2. Step 2: Understand command version differences

    Some older or non-GNU versions of head do not support -n and require different syntax.
  3. Final Answer:

    The head command version does not support -n -> Option B
  4. Quick Check:

    Invalid option error means unsupported flag [OK]
Quick Trick: Check command version if options cause errors [OK]
Common Mistakes:
MISTAKES
  • Assuming file missing causes option error
  • Trying to run as root unnecessarily
  • Using wrong syntax without checking version

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes