Linux下根据端口号查询对应进程

我们经常使用netstat -lnp可以查询对应端口跟进程,但是有些端口是在netstat -lnp里却没显示对应的进程pid,如果我们使用某个端口已经被占用,需要找到对应占用端口的进程关闭之类的,此时可以通过lsof来查询对应端口的对应进程pid号,

[wei@vm-cbu-qa-168-13 web-deploy]$ netstat -lnp    (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:7008                0.0.0.0:*                   LISTEN      27709/java             tcp        0      0 0.0.0.0:6208                0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:800                 0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:7009                0.0.0.0:*                   LISTEN      27709/java             tcp        0      0 127.0.0.1:15777             0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:2049                0.0.0.0:*                   LISTEN      -                      tcp        0      0 127.0.0.1:15778             0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:35559               0.0.0.0:*                   LISTEN      27709/java             tcp        0      0 0.0.0.0:55336               0.0.0.0:*                   LISTEN      27709/java             tcp        0      0 0.0.0.0:4200                0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:58666               0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:845                 0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:4110                0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:4207                0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:20880               0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:4208                0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:18000               0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:18001               0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:18002               0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:42483               0.0.0.0:*                   LISTEN      -                      tcp        0      0 0.0.0.0:48116               0.0.0.0:*                   LISTEN      -                      tcp        0      0 10.20.168.13:8022           0.0.0.0:*                   LISTEN      -          

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/21135.html