Send SIGTERM to processes owned by alice whose name exactly matches backup.
Which command is appropriate?
pkill selects processes by attributes and sends a signal. -u selects the effective user and -x requires an exact name match.
Detailed explanation
kill alice backupIncorrect. kill does not accept a user and process-name filter in this form.
Incorrect. kill does not accept a user and process-name filter in this form.
pgrep -u alice -x backupIncorrect. pgrep only prints matching PIDs and does not send SIGTERM.
Incorrect. pgrep only prints matching PIDs and does not send SIGTERM.
pkill -u alice -x backupCorrect. pkill -u alice -x backup sends the default SIGTERM to matching processes.
Correct. pkill -u alice -x backup sends the default SIGTERM to matching processes.
jobs -u alice backupIncorrect. jobs does not select arbitrary processes by user and name.
Incorrect. jobs does not select arbitrary processes by user and name.
Try it yourself
An example you can run in a temporary verification environment.
pkill --help | grep -E -- '--euid|--exact|-u|-x'Expected result
-uと-x optionのhelpKey points
- pkill
- -u
- -x
Notes
- Environment: procps-ng系pkill help
- 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.