Loading

【经验分享】Linux端口查看常用命令

lsof命令

注意事项:lsof在linux环境下可能需要进行安装后才能使用

安装命令:

yum install lsof
  1. lsof -i 显示所有打开的端口
    ![在这里插入图片描述]( https://img-blog.csdnimg.cn/20210205171833639.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1N1bmxpZ2h0RGVu,size_16,color_FFFFFF,t_70)
  2. lsof -i:8080 显示所有打开8080端口的进程
    在这里插入图片描述

netstat命令

  1. netstat -ntlp 查看当前所有tcp端口
    ![在这里插入图片描述]( https://img-blog.csdnimg.cn/20210205170213797.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1N1bmxpZ2h0RGVu,size_16,color_FFFFFF,t_70)
  2. netstat -ntulp | grep 2375 查看所有2375端口的使用情况
    在这里插入图片描述
  3. netstat -an | grep 3306 查看所有2375端口的使用情况
    在这里插入图片描述
  4. netstat -lanp 查看一台服务器上面哪些服务及端口
    ![在这里插入图片描述]( https://img-blog.csdnimg.cn/20210205170540482.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1N1bmxpZ2h0RGVu,size_16,color_FFFFFF,t_70)
  5. netstat -pnt | grep :8080 |wc 查看某一端口的连接客户端IP 比如8080端口
    在这里插入图片描述
  6. netstat -ntpl 显示TCP类型的端口![在这里插入图片描述]( https://img-blog.csdnimg.cn/20210205171115248.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1N1bmxpZ2h0RGVu,size_16,color_FFFFFF,t_70)
  7. netstat -nupl 显示UDP类型的端口
    在这里插入图片描述
posted @ 2022-01-23 22:28  邓小白  阅读(740)  评论(0)    收藏  举报