Bird
0
0

Why does the history command sometimes show duplicate commands with different numbers after restarting the shell?

hard📝 Conceptual Q10 of 15
Linux CLI - Environment and Configuration
Why does the history command sometimes show duplicate commands with different numbers after restarting the shell?
ABecause the history command caches commands in memory only
BBecause the shell resets command numbers on each start
CBecause duplicate commands are merged automatically
DBecause the history file appends new commands without removing duplicates
Step-by-Step Solution
Solution:
  1. Step 1: Understand history file behavior

    The history file appends commands each session, so duplicates accumulate if not cleaned.
  2. Step 2: Check command numbering

    Command numbers increase but duplicates remain because file is appended, not overwritten.
  3. Step 3: Evaluate other options

    Shell does not reset numbers to 1 each time; history caches in memory but also reads file; duplicates are not merged automatically.
  4. Final Answer:

    Because the history file appends new commands without removing duplicates -> Option D
  5. Quick Check:

    History file appends commands causing duplicates [OK]
Quick Trick: History file appends commands; duplicates appear if not cleaned [OK]
Common Mistakes:
  • Thinking shell resets numbers
  • Assuming duplicates merge
  • Ignoring file append behavior

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes