Bird
0
0

Identify the error in this command: mv file1.txt /home/user/docs when /home/user/docs does not exist.

medium📝 Debug Q6 of 15
Linux CLI - File and Directory Operations
Identify the error in this command: mv file1.txt /home/user/docs when /home/user/docs does not exist.
AThe command will rename file1.txt to docs
BThe command will create the destination directory automatically
CThe command will copy file1.txt instead of moving
DThe command will fail because the destination directory does not exist
Step-by-Step Solution
Solution:
  1. Step 1: Understand mv command behavior

    mv moves files to existing directories; it does not create directories.
  2. Step 2: Check destination directory existence

    If /home/user/docs does not exist, mv will fail with error.
  3. Final Answer:

    The command will fail because the destination directory does not exist -> Option D
  4. Quick Check:

    mv needs existing destination = C [OK]
Quick Trick: Ensure destination directory exists before mv [OK]
Common Mistakes:
  • Assuming mv creates directories
  • Thinking mv copies files
  • Believing mv renames file to directory name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes