Bird
0
0

When executing cd ~nonexistentuser, why does the shell return an error?

medium📝 Debug Q7 of 15
Linux CLI - Navigating the File System
When executing cd ~nonexistentuser, why does the shell return an error?
ABecause the command requires root privileges
BBecause the shell does not support user-specific home shortcuts
CBecause the specified user does not exist on the system
DBecause the tilde cannot be used with usernames
Step-by-Step Solution
Solution:
  1. Step 1: Understand ~username expansion

    The shell expands ~username to that user's home directory if the user exists.
  2. Step 2: Check user existence

    If the user does not exist, the shell cannot resolve the path and returns an error.
  3. Final Answer:

    Because the specified user does not exist on the system -> Option C
  4. Quick Check:

    Try cd ~root if root exists, it works; else error [OK]
Quick Trick: User must exist for ~username to work [OK]
Common Mistakes:
  • Assuming ~username works without user existing
  • Thinking root privileges are needed
  • Believing tilde can't be combined with usernames

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes