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 [选项] 进程名/进程条件

常用的选择:

  1. -u : specifies the user.
  2. -g : specify the process group.
  3. Parent process: specify the parent process.
  4. -t : Specify the terminal.
  5. -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 to forcefully kill the process.

bannerAds