Bird
0
0

What happens when you run ls -l /var/log | less and press the q key?

medium📝 Command Output Q5 of 15
Linux CLI - Viewing and Editing Files
What happens when you run ls -l /var/log | less and press the q key?
AClears the screen but stays in less
BQuits the ls command immediately
CExits the less viewer and returns to the shell prompt
DScrolls to the end of the output
Step-by-Step Solution
Solution:
  1. Step 1: Understand the behavior of less on pressing 'q'

    Pressing 'q' quits the less pager and returns control to the shell.
  2. Step 2: Analyze the command pipeline

    ls -l /var/log output is piped to less, so quitting less ends viewing but does not affect ls which already completed.
  3. Final Answer:

    Exits the less viewer and returns to the shell prompt -> Option C
  4. Quick Check:

    Pressing 'q' quits less [OK]
Quick Trick: Press 'q' to quit less and return to shell [OK]
Common Mistakes:
MISTAKES
  • Thinking 'q' quits ls command
  • Expecting scroll to end
  • Assuming screen clears but stays
  • Confusing with other keys

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes