Traverse /home directly and find regular files owned by alice.
Exclude directories from the results.
Which command is appropriate?
find -user NAME tests file ownership. Combining it with -type f limits the result to regular files.
Detailed explanation
find /home -group alice -type fIncorrect. -group tests the owning group, not the user owner.
Incorrect. -group tests the owning group, not the user owner.
find /home -name alice -type fIncorrect. -name tests a pathname pattern, not file ownership.
Incorrect. -name tests a pathname pattern, not file ownership.
locate --user alice /homeIncorrect. locate searches an index and does not use this direct ownership predicate.
Incorrect. locate searches an index and does not use this direct ownership predicate.
find /home -type f -user aliceCorrect. find /home -type f -user alice finds alice-owned regular files.
Correct. find /home -type f -user alice finds alice-owned regular files.
Try it yourself
An example you can run in a temporary verification environment.
find /home -maxdepth 2 -type f -user "$(id -un)" -printExpected result
現在の利用者が所有する該当ファイルKey points
- -user selects owner
- Different from -group
- Predicates are combined
Notes
- Environment: GNU findutils 4.9以降
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.