美文网首页
查看端口或者进程命令(netstat & lsof)

查看端口或者进程命令(netstat & lsof)

作者: 含泪若笑 | 来源:发表于2020-08-27 09:16 被阅读0次

1 仅限 Linux

netstat  -anp  |grep  270/docker  查看端口/应用 有没有被用

-a 或–all 显示所有连线中的Socket。

-t 或–tcp 显示TCP 传输协议的连线状况。

-n 或–numeric 直接使用IP地址,而不通过域名服务器

grep 命令用于查找文件里符合条件的字符串。

2 仅限mac

如果需要查询inet,netstat -anvf inet        netstat -anvf  inet | grep 9000

如果需要查询TCP, netstat -anvp tcp        netstat -anvp tcp | grep 9000

lsof -i -P -n | grep 8080  ( -n no host names   -P no port names )

lsof -i:8080 (-i表示端口)

lsof -i tcp:8080 查看8080端口的TCP情况

3 Mac and Linux

ps -ef | grep docker/9000  (-e 显示所有进程。-f 全格式)

其实最好用的是help,    netstat -h,哈哈 。

相关文章

网友评论

      本文标题:查看端口或者进程命令(netstat & lsof)

      本文链接:https://www.haomeiwen.com/subject/usferktx.html