Without further ado, this article introduces common Linux operations: check the process that occupies the port and kill the process according to the PID. Add: View process PID by program name.

First, two commands, lsof and netstat.Copy the code

Method 1: lsof command 1. Check the PID of the process that occupies the port.

Lsof -i:{port number}Copy the code

2, Kill the process according to PID:

kill 9 - {PID}
Copy the code

Method 2: run the netstat command to check the PID of the process that occupies the port.

netstat -tunlp|grep {port}
Copy the code

2, kill method above.

 kill 9 - {PID}
Copy the code

1, use ps command (zb only) :

ps -ef | grep {programName}
kill 9 - {PID}
Copy the code

View detailed memory usage

ps aux -u root | grep {programName}
Copy the code

2. Run the pgrep command:

The p of the pgrep command indicates that this command is specifically grep for process queries.

pgrep {programName}
kill 9 - {PID}
Copy the code

Supplement 2: View the process based on the PID

ps -aux |grep -v grep|grep {$PID}
Copy the code

Want to know more about the technology and I understand