nerdexam
Linux_Foundation

LFCS · Question #861

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 is used to locate files and directories within a specified path based on various criteria, including ownership, and will print the results.

Submitted by renata2k· Apr 18, 2026Essential 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

(36 responses)
  • A
    6% (2)
  • B
    3% (1)
  • C
    92% (33)

Why each option

The `find` command is used to locate files and directories within a specified path based on various criteria, including ownership, and will print the results.

Afind /tmp -uid root -print

The `-uid` option for the `find` command expects a numeric User ID (UID), not a username like `root`, so this command would not correctly identify files by username.

Bfind -path /tmp -uid root

The `-path` option is used to match a specific path pattern, not to specify the starting directory for the search; the starting directory (`/tmp`) must be the first argument to `find`, and `-uid` requires a numeric ID.

Cfind /tmp -user root -printCorrect

The command `find /tmp -user root -print` correctly searches the `/tmp` directory and its subdirectories, identifying all files and directories owned by the `root` user, and then explicitly prints their paths to standard output.

Dfind /tmp -user rootCorrect

The command `find /tmp -user root` is also correct because the `find` command, by default, performs the `-print` action if no other action (like `-exec` or `-delete`) is specified, making it functionally equivalent to explicitly including `-print` for this purpose.

Efind -path /tmp -user root print

The `-path` option is incorrectly used here for specifying the starting directory, and the `print` action is misplaced as it should typically be preceded by a hyphen or be implicitly called as a default action.

Concept tested: find command by user ownership

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

Topics

#find command#file search#file ownership#command syntax

Community Discussion

No community discussion yet for this question.

Full LFCS Practice