pkill Command Guide: Use in Linux
The pkill command is used to terminate processes based on the process name or other conditions.
Follow the format:
pkill [选项] 进程名/进程条件
常用的选择:
- -u
: specifies the user. - -g
: specify the process group. - Parent process: specify the parent process.
- -t
: Specify the terminal. - -F: Use exact name matching.
For instance, to terminate all processes named “example,” you can use the following command:
pkill example
To terminate all processes named “example” and specify the user as “root,” you can use the following command:
pkill -u root example
Note: the pkill command will send a SIGTERM signal to the matching process, if the process cannot exit normally, you can use kill -9