nerdexam
LPI

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.

Finding Your Way on a Linux System

Question

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?

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)
  • A
    17% (10)
  • B
    3% (2)
  • C
    2% (1)
  • D
    71% (42)
  • E
    7% (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.

A/home/user/Documents/

/home/user/Documents/ would require only a single .. from Downloads/ then appending Documents/, not the two-level traversal used in the command.

B/home/user/Documents/Downloads/

/home/user/Documents/Downloads/ cannot result from any path traversal of the given command and is not a logical relative resolution.

C/home/user/Downloads/Documents/

/home/user/Downloads/Documents/ would result from ls Documents/ with no parent traversal at all.

D/Documents/Correct

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.

E/home/Documents

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

#relative paths#path traversal#directory navigation#dot-dot notation

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice