![](https://i1.wp.com/www.linuxcommands.site/wp-content/uploads/2019/05/image-60.png?fit=640%2C283&ssl=1)
Query the name of the running process, usually requires the linux ps command, linux netstat command, linux awk command and the linux grep command.
grep process by name
➜ ps -ef | grep nginx
![](https://i0.wp.com/www.linuxcommands.site/wp-content/uploads/2019/05/image-61.png?fit=640%2C56&ssl=1)
grep process by port
➜ grep netstat -an | grep "\*\.8080"
![](https://i2.wp.com/www.linuxcommands.site/wp-content/uploads/2019/05/image-62.png?fit=640%2C50&ssl=1)
grep process id and kill
➜ ps -ef | grep "tail" | grep -v grep | awk -F" " 'system("kill "$2"")'
![](https://i1.wp.com/www.linuxcommands.site/wp-content/uploads/2019/05/image-65.png?fit=640%2C151&ssl=1)
Command interpretation:
step 1. Show the process you want to kill and exclude the grep command.
➜ ps -ef | grep "tail" | grep -v grep
![](https://i1.wp.com/www.linuxcommands.site/wp-content/uploads/2019/05/image-66.png?fit=640%2C273&ssl=1)
step 2. Get the process pid you want to kill.
➜ grep ps -ef | grep "tail -f" | grep -v grep | awk -F" " '{print $2}'
![](https://i1.wp.com/www.linuxcommands.site/wp-content/uploads/2019/05/image-67.png?fit=640%2C65&ssl=1)
![](https://i0.wp.com/www.linuxcommands.site/wp-content/uploads/2019/05/image-68.png?fit=640%2C93&ssl=1)
step 3. Kill the process with awk system.
➜ ps -ef | grep "tail" | grep -v grep | awk -F" " 'system("kill "$2"")'