LFCA practice question 13 of 15

What command do you use to view the structure of system directory hierarchies?

Full set: 60 questions

Domain Linux Fundamentals

Answer options
A: tree Correct answer
B: fee | ls /etc
C: ls -t
D: ls tree
Correct Answer:
A. tree
Explanation

The tree command is a standard Linux utility specifically designed to recursively list or display the contents of a directory in a depth-indented, tree-like format. This visual representation directly shows the hierarchical structure of directories, subdirectories, and files, starting from a specified root directory (or the current directory if none is given). It is the most appropriate and direct tool for the task described in the question, which is to view the structure of directory hierarchies.

Why Incorrect

B. fee | ls /etc: fee is not a standard command, and this command structure is syntactically incorrect for viewing a directory hierarchy.
C. ls -t: This command lists the contents of a directory sorted by modification time; it does not display the hierarchical structure.
D. ls tree: This command would attempt to list the contents of a file or directory literally named "tree", not execute the tree utility. ---

References

1. Official Vendor Documentation (man page): The tree manual page provides the definitive description of the command's function.

Source: tree(1) — Linux manual page.

Reference: In the "NAME" section, it states: "tree - list contents of directories in a tree-like format." The "DESCRIPTION" section further elaborates that "Tree is a recursive directory listing program that produces a depth indented listing of files."

2. University Courseware: Reputable computer science courses often introduce tree as a fundamental tool for filesystem visualization.

Source: MIT, "The Missing Semester of Your CS Education," Lecture 2: Shell Tools and Scripting.

Reference: In the "Files and Directories" section, the course notes demonstrate the use of tree to visualize directory structures, contrasting it with the flat listing provided by ls.

3. Official Vendor Documentation (Red Hat): Major Linux distribution documentation covers essential command-line utilities.

Source: Red Hat Enterprise Linux 9 Documentation, "Configuring basic system settings," Chapter 2. Working with the command line.

Reference: Section 2.1.3, "Listing files and directories," describes the ls command and its options. While tree may not be installed by default, its function is distinct from ls, which is used for listing contents, not displaying the full hierarchical structure recursively in a visual format. This distinction highlights why ls -t is incorrect.

Scroll to Top