Bird
0
0

Given this directory structure:

medium📝 Command Output Q13 of 15
Linux CLI - File and Directory Operations
Given this directory structure:
project/
├── file1.txt
├── folderA/
│   └── file2.txt
└── folderB/
    └── file3.txt

What happens after running rm -r project/folderA?
AfolderA and file2.txt are deleted, other files remain.
BOnly file2.txt is deleted, folderA remains.
CEntire project folder is deleted.
DCommand fails with an error.
Step-by-Step Solution
Solution:
  1. Step 1: Identify target folder

    The command targets project/folderA, so only that folder and its contents are affected.
  2. Step 2: Understand recursive deletion

    Using -r deletes folderA and everything inside it, including file2.txt, but leaves other folders and files intact.
  3. Final Answer:

    folderA and file2.txt are deleted, other files remain. -> Option A
  4. Quick Check:

    rm -r deletes target folder and contents only = B [OK]
Quick Trick: rm -r deletes only specified folder and contents, not siblings [OK]
Common Mistakes:
MISTAKES
  • Thinking only files inside folderA are deleted but folder remains
  • Assuming entire project folder is deleted
  • Expecting command to fail without error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes