Linux下查看tomcat占用端口

    xiaoxiao2022-07-02  86

    步骤:

    ps查看进程号

    netstat查看进程号对应进程占用得端口号

    lsof -i查看端口号所属进程号得相关信息

    1、先查看tomcat的进程号

    ps -ef | grep tomcat*

    后面带*号,是为了查看多个tomcat,例如tomcat6,tomcat7。

    2、根据进程号查看端口号

    netstat -anop | grep 15161

    可以看到8865、8866、8867端口号被占用

    3、此外,还可以通过端口号,查看其所属的进程号相关信息

    lsof -i: 8866

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Linux 查看端口占用情况

    Linux 查看端口占用情况可以使用 lsof 和 netstat 命令。

    lsof

      lsof(list open files)是一个列出当前系统打开文件的工具。

      lsof 查看端口占用语法格式:

    lsof -i:端口号

                   

                     

    netstat

    netstat -tunlp 用于显示 tcp,udp 的端口和进程等相关情况。

    netstat 查看端口占用语法格式:

    netstat -tunlp | grep 端口号 -t (tcp) 仅显示tcp相关选项-u (udp)仅显示udp相关选项-n 拒绝显示别名,能显示数字的全部转化为数字-l 仅列出在Listen(监听)的服务状态-p 显示建立相关链接的程序名

    例如查看 8000 端口的情况,使用以下命令:

    # netstat -tunlp | grep 8000 tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 26993/nodejs

             

     

    最新回复(0)