Bird
0
0

You are in /var/www/html. You want to copy a file index.html from /home/user/website to your current directory using a relative path. Which command is correct?

hard📝 Application Q15 of 15
Linux CLI - Navigating the File System
You are in /var/www/html. You want to copy a file index.html from /home/user/website to your current directory using a relative path. Which command is correct?
A<code>cp /home/user/website/index.html .</code>
B<code>cp ../../home/user/website/index.html .</code>
C<code>cp ../../../../home/user/website/index.html .</code>
D<code>cp ../../../home/user/website/index.html .</code>
Step-by-Step Solution
Solution:
  1. Step 1: Calculate relative path from /var/www/html to /home/user/website

    From /var/www/html, going up three levels: html -> www -> var reaches /. Then go into home/user/website.
  2. Step 2: Form the relative path

    The relative path is ../../../home/user/website/index.html. So the command is cp ../../../home/user/website/index.html ..
  3. Final Answer:

    cp ../../../home/user/website/index.html . -> Option D
  4. Quick Check:

    3 ups to root, then home path = ../../../home/user/website [OK]
Quick Trick: Count folders up to root, then add full path [OK]
Common Mistakes:
MISTAKES
  • Using too few ../ and missing root
  • Using absolute path when asked for relative
  • Confusing current directory (.) with parent (..)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes