010-160 · Question #38
A user is currently in the directory /home/user/Downloads/ and runs the command ls ../../Documents/ Assuming it exists, which directory's content is displayed?
The correct answer is D. /Documents/. Resolving ls ../../Documents/ from /home/user/Downloads/ requires stepping up two parent directories then appending Documents/, which yields /home/Documents/ - matching choice E, not D.
Question
Options
- A/home/user/Documents/
- B/home/user/Documents/Downloads/
- C/home/user/Downloads/Documents/
- D/Documents/
- E/home/Documents
How the community answered
(59 responses)- A17% (10)
- B3% (2)
- C2% (1)
- D71% (42)
- E7% (4)
Why each option
Resolving ls ../../Documents/ from /home/user/Downloads/ requires stepping up two parent directories then appending Documents/, which yields /home/Documents/ - matching choice E, not D.
/home/user/Documents/ would require only a single .. from Downloads/ then appending Documents/, not the two-level traversal used in the command.
/home/user/Documents/Downloads/ cannot result from any path traversal of the given command and is not a logical relative resolution.
/home/user/Downloads/Documents/ would result from ls Documents/ with no parent traversal at all.
NOTE - The marked answer D (/Documents/) appears to be a question error. From /home/user/Downloads/, the first .. resolves to /home/user/, the second .. resolves to /home/, and appending Documents/ yields /home/Documents/ - which matches choice E. Reaching /Documents/ would require three levels of .. traversal, not two.
Based on correct path resolution, /home/Documents is actually the correct result - the question's marked answer D appears to be an error in the exam key.
Concept tested: Linux relative path navigation using parent directory traversal
Source: https://www.gnu.org/software/coreutils/manual/coreutils.html#ls-invocation
Topics
Community Discussion
No community discussion yet for this question.