Bird
0
0

Find the mistake in this command sequence: touch report.txt; cp report.txt /backup/reports/ when /backup/reports/ is a file, not a directory.

medium📝 Debug Q7 of 15
Linux CLI - File and Directory Operations
Find the mistake in this command sequence: touch report.txt; cp report.txt /backup/reports/ when /backup/reports/ is a file, not a directory.
Acp will create a directory named reports
Bcp will overwrite the file /backup/reports/ with report.txt
Ccp will rename report.txt to reports
Dcp will fail because /backup/reports/ is not a directory
Step-by-Step Solution
Solution:
  1. Step 1: Understand cp behavior with trailing /

    cp to a path ending in / expects the destination to be a directory.
  2. Step 2: /backup/reports/ is a file, not directory

    cp will fail because it cannot copy into a non-directory.
  3. Final Answer:

    cp will fail because /backup/reports/ is not a directory -> Option D
  4. Quick Check:

    cp to file-with-/ destination = C [OK]
Quick Trick: Check if destination is file or directory before cp [OK]
Common Mistakes:
MISTAKES
  • Expecting cp to create directory
  • Thinking cp will overwrite the file /backup/reports/ with report.txt
  • Assuming cp renames files

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes