nerdexam
Linux_Foundation

LFCS · Question #830

In a nested directory structure, which find command line option would be used to restrict the command to searching down a particular number of subdirectories?

The correct answer is B. -maxdepth. The find command uses the -maxdepth option to limit the search to a specified number of subdirectories below the starting point, preventing it from traversing deeper into the directory tree.

Submitted by amina.ke· Apr 18, 2026Essential Commands

Question

In a nested directory structure, which find command line option would be used to restrict the command to searching down a particular number of subdirectories?

Options

  • A-dirmax
  • B-maxdepth
  • C-maxlevels
  • D-n
  • E-s

How the community answered

(67 responses)
  • A
    7% (5)
  • B
    87% (58)
  • C
    4% (3)
  • E
    1% (1)

Why each option

The `find` command uses the `-maxdepth` option to limit the search to a specified number of subdirectories below the starting point, preventing it from traversing deeper into the directory tree.

A-dirmax

`dirmax` is not a valid or standard option for the `find` command to restrict search depth.

B-maxdepthCorrect

The `-maxdepth` option for the `find` command specifies the maximum number of levels of directories that `find` will descend. For example, `-maxdepth 1` would only search the starting directory and no subdirectories.

C-maxlevels

`maxlevels` is not a valid or standard option for the `find` command to restrict search depth.

D-n

The `-n` option for `find` is not used for limiting search depth; it's often used with other commands for line numbering or similar purposes.

E-s

The `-s` option for `find` is not used for limiting search depth; it's typically used for silent mode or for sorting results depending on the command.

Concept tested: Find command directory depth restriction

Source: https://man7.org/linux/man-pages/man1/find.1.html

Topics

#find command#directory searching#command line utilities

Community Discussion

No community discussion yet for this question.

Full LFCS Practice