Skip to main content
Linux AdministrationMediumSingle Choice

Linux Administration Question

Statement

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?

#find#maxdepth#directory-traversal#search-depth
A

-dirmax

B

-maxdepth

Correct
C

-maxlevels

D

-n

E

-s

Resolution & Explanations

The find command in Linux is used to search for files and directories within a directory hierarchy. The -maxdepth option restricts the search to a specified number of subdirectory levels. For example, find /path -maxdepth 2 will search only the starting directory and its immediate subdirectories, but not deeper. This is useful for limiting the scope of a search to avoid traversing large directory trees.