linux查看系统端口使用情况命令netstat | lsof -i

基于ubuntu 18.04版本。

列出所有端口情况

# netstat -nutlp / lsof -i:3306

查看端口使用情况

# netstat -nutlp | grep 8000
# -n:以ip:port显示,-tu:tcp/udp,显示listenning,-p:显示pid/program 名称

# root@ubuntu:/home/ubuntu# netstat -ntulp | grep 8000
# tcp        0      0 0.0.0.0:8000            0.0.0.0:*               LISTEN      101060/python2.7 

# netstat -nutlp | grep ssh
# netstat -nutlp | grep http

tips

ubuntu 安装netstat, 安装命令:apt-get install net-tools
centos 默认没安装netstat,需要先安装net-tools

# sudo yum -y install net-tools

以数字、pid/program显示所有的网络信息:

# netstat -anp

posted on 2021-01-15 15:02  进击的davis  阅读(302)  评论(0编辑  收藏  举报

导航