nerdexam
CompTIA

LX0-103 · Question #48

Which of the following commands prints all files and directories within the /tmp directory or its subdirectories which are also owned by the user root? (Choose TWO correct answers.)

The correct answer is C. find /tmp -user root -print D. find /tmp -user root. The find command's -user option matches files by owner username, and -print is the default action so it can be omitted or included explicitly.

GNU and Unix Commands

Question

Which of the following commands prints all files and directories within the /tmp directory or its subdirectories which are also owned by the user root? (Choose TWO correct answers.)

Options

  • Afind /tmp -uid root -print
  • Bfind -path /tmp -uid root
  • Cfind /tmp -user root -print
  • Dfind /tmp -user root
  • Efind -path /tmp -user root print

How the community answered

(34 responses)
  • B
    3% (1)
  • C
    91% (31)
  • E
    6% (2)

Why each option

The find command's -user option matches files by owner username, and -print is the default action so it can be omitted or included explicitly.

Afind /tmp -uid root -print

The -uid option requires a numeric user ID, not a username string; passing the word 'root' to -uid is invalid and will cause an error.

Bfind -path /tmp -uid root

The -path option matches against the file's path using a glob pattern, not a starting directory; using it instead of specifying the search root is incorrect syntax.

Cfind /tmp -user root -printCorrect

find /tmp -user root -print searches /tmp recursively for files owned by the username root and explicitly prints each matching path with -print.

Dfind /tmp -user rootCorrect

find /tmp -user root is equivalent because -print is the implicit default action when no other action is specified, producing identical output without the explicit flag.

Efind -path /tmp -user root print

The -path option is misused as a directory argument, and 'print' without a leading hyphen is not a valid find action predicate, making this command syntactically wrong.

Concept tested: find command filtering files by owner with -user

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

Topics

#find#file ownership#-user option#directory traversal

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice