伊谢尔伦2017-04-17 16:04:19
查看伺服器監聽的連接埠:
$ ss -tunl
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
tcp LISTEN 0 128 *:6378 *:*
tcp LISTEN 0 128 :::6378 :::*
tcp LISTEN 0 128 :::80 :::*
tcp LISTEN 0 128 :::22 :::*
tcp LISTEN 0 128 *:22 *:*
tcp LISTEN 0 100 ::1:25 :::*
tcp LISTEN 0 100 127.0.0.1:25 *:*
查看80埠被哪個程式佔用
$ lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 2666 root 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2668 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2669 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2670 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2671 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2672 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2673 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2674 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
httpd 2675 apache 4u IPv6 15095 0t0 TCP *:http (LISTEN)
你可以使用lsof查看連接埠被哪個服務佔用了,然後停用那個服務就好了。
如果沒有lsof指令,可以使用apt-get安裝,
$ sudo apt-get install lsof
查找PID的方式建議用ps
指令ps
命令
$ ps aux | grep httpd
root 2666 0.0 0.3 177344 3836 ? Ss 14:31 0:00 /usr/sbin/httpd
apache 2668 0.0 0.2 177344 2452 ? S 14:31 0:00 /usr/sbin/httpd
apache 2669 0.0 0.2 177344 2452 ? S 14:31 0:00 /usr/sbin/httpd
apache 2670 0.0 0.2 177344 2468 ? S 14:31 0:00 /usr/sbin/httpd
apache 2671 0.0 0.2 177344 2452 ? S 14:31 0:00 /usr/sbin/httpd
apache 2672 0.0 0.2 177344 2452 ? S 14:31 0:00 /usr/sbin/httpd
apache 2673 0.0 0.2 177344 2452 ? S 14:31 0:00 /usr/sbin/httpd
apache 2674 0.0 0.2 177344 2452 ? S 14:31 0:00 /usr/sbin/httpd
apache 2675 0.0 0.2 177344 2452 ? S 14:31 0:00 /usr/sbin/httpd
root 3469 0.0 0.0 103308 888 pts/4 S+ 19:16 0:00 grep httpd
$ sudo killall -9 $pid
or
$ sudo killall -15 $pid
killall -9
是强制杀死killall -15
rrreee
killall -9
是強制殺死killall -15
是讓程式儲存目前資料後慢慢關閉🎜