
illust_69727994_20180729_094516.png
0x01 查看端口对应的 PID
- 可以用这 3 种方式:
lsof -i:端口netstat -tunlp | grep 端口netstat -apn | grep 端口
lsof -i:端口
h2o2@ubt:~$ lsof -i:1080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
python 19183 h2o2 3u IPv4 140160 0t0 TCP localhost:socks (LISTEN)
python 19183 h2o2 4u IPv4 140161 0t0 UDP localhost:socks
netstat -tunlp | grep 端口
h2o2@ubt:~$ netstat -tunlp | grep 1080
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
tcp 0 0 127.0.0.1:1080 0.0.0.0:* LISTEN 19183/python
udp 0 0 127.0.0.1:1080 0.0.0.0:* 19183/python
-
netstat -apn | grep 端口或netstat -apn | grep 端口 | grep LISTEN
h2o2@ubt:~$ netstat -apn | grep 1080
(并非所有进程都能被检测到,所有非本用户的进程信息将不会显示,如果想看到所有信息,则必须切换到 root 用户)
tcp 0 0 127.0.0.1:1080 0.0.0.0:* LISTEN 19183/python
tcp 4 0 127.0.0.1:1080 127.0.0.1:44556 CLOSE_WAIT -
tcp 4 0 127.0.0.1:1080 127.0.0.1:44558 CLOSE_WAIT -
tcp 4 0 127.0.0.1:1080 127.0.0.1:44554 CLOSE_WAIT -
udp 0 0 127.0.0.1:1080 0.0.0.0:* 19183/python
- 查看占用这个端口的用户
lsof -i:端口ps -ef | grep 端口
ps -ef | grep 端口
h2o2@ubt:~$ ps -ef | grep 1080
h2o2 19808 19409 0 19:42 pts/6 00:00:00 grep --color=auto 1080
0x02 Kail 进程
-
kill -9 PID: 强制杀死进程