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.
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)- B3% (1)
- C91% (31)
- E6% (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.
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.
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.
find /tmp -user root -print searches /tmp recursively for files owned by the username root and explicitly prints each matching path with -print.
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.
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
Community Discussion
No community discussion yet for this question.