Bird
0
0

You want to save only the last 50 commands to your history file and discard older ones automatically. Which approach achieves this?

hard📝 Application Q9 of 15
Linux CLI - Environment and Configuration
You want to save only the last 50 commands to your history file and discard older ones automatically. Which approach achieves this?
ADelete ~/.bash_history manually every time
BRun <code>history -w</code> after every command
CSet <code>HISTSIZE=50</code> and <code>HISTFILESIZE=50</code> in your shell config
DUse <code>history -c</code> every 50 commands
Step-by-Step Solution
Solution:
  1. Step 1: Understand history size variables

    HISTSIZE controls how many commands are kept in memory; HISTFILESIZE controls how many are saved to file.
  2. Step 2: Set both to 50 to limit history length

    This ensures only last 50 commands are saved and remembered.
  3. Step 3: Evaluate other options

    history -w writes current history to file but doesn't limit size; history -c clears all history; manual deletion is inefficient.
  4. Final Answer:

    Set HISTSIZE=50 and HISTFILESIZE=50 in your shell config -> Option C
  5. Quick Check:

    Limit history size with HISTSIZE and HISTFILESIZE [OK]
Quick Trick: Configure HISTSIZE and HISTFILESIZE to limit history length [OK]
Common Mistakes:
  • Using history -w to limit size
  • Clearing history too often
  • Manual file deletion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes