If you know the name of the process, you can use pkill [OPTIONS] <PATTERN> to kill all running programs that match with the given name. To kill all python3 process:
1
pkill node # kill all node applications
Example
kill a process
kill without option will send SIGTERM signal. Use ps aux | grep <search keywork> to get the process id. Then use kill command to kill the process.
1
kill 16575
Send KILL signal to a process
1
kill -9 16575
or
1
kill -s KILL 16575
List signal names
1
kill -l
To kill a process by pid
use ps aux or pgreg command to get the process’s PID.
1
ps aux | grep node
In MacOS, if you only know the port number used by the application, you can get the PID and command using the following command
1
sudo lsof -iTCP -sTCP:LISTEN -n -P
With the process id, You can use kill <pid> to terminate the program. The default sends SIGTERM signal. You can use kill -9 <pid> command to send SIGKILL to terminate immediately. SIGKILL is hard kill.