Find regular files under /srv/data owned by alice.
Which GNU find command is appropriate?
find -user NAME tests the owning user; -group tests the owning group and -name tests the filename.
Detailed explanation
find /srv/data -type f -group aliceIncorrect. -group alice tests the group name.
Incorrect. -group alice tests the group name.
find /srv/data -type f -name aliceIncorrect. -name alice tests the file name.
Incorrect. -name alice tests the file name.
find /srv/data -type f -user aliceCorrect. find /srv/data -type f -user alice selects alice-owned regular files.
Correct. find /srv/data -type f -user alice selects alice-owned regular files.
find /srv/data -type f -perm aliceIncorrect. -perm tests mode bits rather than an owner name.
Incorrect. -perm tests mode bits rather than an owner name.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); touch "$tmp/mine"; find "$tmp" -type f -user "$(id -un)" -printf '%f\n'; rm -rf "$tmp"Expected result
mineKey points
- -user is owner
- -group is owning group
- -name is filename
Notes
- Environment: GNU findutils 4.x / 現在の利用者が所有する一時ファイル
- 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.