Linux Foundation Certified System Administrator: LFCS Exam Answer

Find Files and Directories Owned by Root in /tmp | LFCS Exam Answer

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.)

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

CD

The correct answers are C and D.

Explanation:

  • The find command is used to search for files and directories in a directory hierarchy.
  • The -user option is used to find files and directories owned by a particular user.
  • The -uid option is used to find files and directories owned by a particular user ID.
  • The /tmp directory is the directory being searched.
  • The -print option is used to print the names of the files and directories found.

Option A: find /tmp -uid root -print This option searches for files and directories owned by the user ID root. The -uid option is used instead of -user, which searches for files and directories owned by the username root. This option will not give the desired result, as it searches for files owned by the user ID and not the username.

Option B: find -path /tmp -uid root This option searches for files and directories that match the path /tmp and are owned by the user ID root. However, the -print option is missing, so the names of the files and directories found will not be displayed.

Option C: find /tmp -user root -print This option searches for files and directories owned by the username root in the /tmp directory and its subdirectories. The -print option is used to print the names of the files and directories found. This option satisfies the conditions mentioned in the question and is correct.

Option D: find /tmp -user root This option searches for files and directories owned by the username root in the /tmp directory and its subdirectories. The names of the files and directories found will not be displayed. This option satisfies the conditions mentioned in the question and is correct.

Option E: find -path /tmp -user root -print This option searches for files and directories that match the path /tmp and are owned by the username root. However, the -print option is misspelled with an extra dash (-print) and will not work. Additionally, this option searches only for files and directories that match the path /tmp and not its subdirectories.

Therefore, options C and D are the correct answers.