系统相关
首页 > 系统相关> > Ubuntu终端命令--查看端口占用及关闭

Ubuntu终端命令--查看端口占用及关闭

作者:互联网

1、查看已经连接的服务端口(ESTABLISHED)
netstat -a
1.
2、查看所有的服务端口(LISTEN,ESTABLISHED)
netstat -ap
1.
3、查看指定端口,可以结合 grep 命令:
netstat -ap | grep 8080
1.
也可以使用 lsof 命令:

lsof -i:8888
1.
4、若要关闭使用这个端口的程序,使用kill + 对应的pid
kill -9 PID号
1.
Ps:kill 就是给某个进程 id 发送了一个信号。

默认发送的信号是 SIGTERM,而 kill -9 发送的信号是 SIGKILL,即 exit。

exit 信号不会被系统阻塞,所以 kill -9 能顺利杀掉进程。

Ubuntu终端命令--查看端口占用及关闭
https://blog.51cto.com/aiyc/2886117

标签:查看,--,netstat,端口,命令,kill,信号,Ubuntu
来源: https://www.cnblogs.com/wujie-code/p/16412426.html