linux 查看占用端口并kill掉

时间:2022-05-25 21:14:24

主要可以使用ps  命令 或 netstat 命令

weihong@data1:~/jd_parser/jd_parser$ ps aux | head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 0.0 0.0 ? Ss 1月18 : /sbin/init
root 0.0 0.0 ? S 1月18 : [kthreadd]
root 0.0 0.0 ? S 1月18 : [ksoftirqd/] weihong@data1:~/jd_parser/jd_parser$ netstat -tlnp | head
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0.0.0.0: 0.0.0.0:* LISTEN -
tcp 127.0.0.1: 0.0.0.0:* LISTEN -
tcp 127.0.0.1: 0.0.0.0:* LISTEN -

weihong@data1:~/jd_parser/jd_parser$ netstat -tlnp | grep
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0.0.0.0: 0.0.0.0:* LISTEN /python
tcp6 ::: :::* LISTEN /python
weihong@data1:~/jd_parser/jd_parser$ kill -