Bird
0
0

You want to create a script that copies a file named notes.txt from your home directory to a backup folder inside your Documents. Which command correctly uses the ~ shortcut?

hard📝 Application Q15 of 15
Linux CLI - Navigating the File System
You want to create a script that copies a file named notes.txt from your home directory to a backup folder inside your Documents. Which command correctly uses the ~ shortcut?
Acp notes.txt ~/Documents/backup/
Bcp ~/notes.txt ~/Documents/backup/
Ccp ~/notes.txt /Documents/backup/
Dcp /notes.txt ~/Documents/backup/
Step-by-Step Solution
Solution:
  1. Step 1: Identify source file path

    The file notes.txt is in the home directory, so ~/notes.txt correctly points to it.
  2. Step 2: Identify destination folder path

    The backup folder is inside Documents in home, so ~/Documents/backup/ is the correct destination path.
  3. Step 3: Check other options

    /notes.txt is root directory file (likely wrong), /Documents/backup/ is absolute path outside home, and notes.txt without path means current directory, not home.
  4. Final Answer:

    cp ~/notes.txt ~/Documents/backup/ -> Option B
  5. Quick Check:

    Use ~ for home paths in source and destination [OK]
Quick Trick: Use ~ before filenames to refer to your home folder [OK]
Common Mistakes:
  • Using absolute paths outside home by mistake
  • Omitting ~ and assuming current directory is home
  • Confusing source and destination paths

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes